how to remove json object key and value.?

后端 未结 6 1351
忘了有多久
忘了有多久 2021-02-01 02:02

I have a json object as shown below. where i want to delete the \"otherIndustry\" entry and its value by using below code which doesn\'t worked.

var updatedjsono         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 02:19

    Follow this, it can be like what you are looking:

    var obj = {
        Objone: 'one',
        Objtwo: 'two'
    };
    
    var key = "Objone";
    delete obj[key];
    console.log(obj); // prints { "objtwo": two}

提交回复
热议问题