简体   繁体   中英

How to save data in object in Javascript

I have this object and I want to save data in the Obj.document.metadata.name example: newData = Obj.document.metadata.name
but it didn't work. I will appreciate all answers.

var Obj =
        {
            "document": {
                "metadata": {
                    "name": "",
                    "date": "",
                    "autor": ""
                 } 
             }
         }
Obj.document.metadata.name="Xerardoo"

temporarily you can save this way. But it will be lost if page refresh

你也可以这样

Obj["document"]["metadata"]["name"] = "Value"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM