js json objects to add, delete, modify property

 

turn:

js json objects to add, delete, modify the properties of
the original LLL_LH Posted on 2018-03-12 12:00:28 reading number 34518 collection
launched

<Script type = "text / JavaScript">
         // json objects 
        var json = { "firstName": "Bill", "lastName": "Gates" };
         // add new properties to json and populate 
        json.sex = "man" ;
         // You can also add the following new properties and assign 
        json [ "Sex"] = "man" ; 


        // delete json object firstName attribute 
        delete json.firstName;
         // you can also delete the following values firstName attribute 
        delete json [ "firstName" ]; 


        // modified values json object firstName property 
        json.firstName = "Thomas" ;
        // may be modified as follows firstName property values 
        JSON [ "firstName"] = "Thomas" ;
     </ Script>

 


----------------
Disclaimer: This article is the original article CSDN bloggers "LLL_LH", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/LLL_liuhui/article/details/79525113

Guess you like

Origin www.cnblogs.com/libin6505/p/12144310.html