如何更改数组对象中的值?

var stooges = [

            {label:1,value:1,placeCode: 'sh', stock_code: 40},

            {label:1,value:1,placeCode: 'sh', stock_code: 50},

            {label:1,value:1,placeCode: 'sz', stock_code: 60,status:1},

            {label:1,value:1,placeCode: 'sz', stock_code: 39,status:1}

        ];

我想将上面代码里的placeCode改变值:"sh"改为"沪","sz"改为"深",请问如何操作,最好用underscore.js或lodash.js

呼如林
浏览 456回答 1
1回答

皈依舞

for(var i=0;i<stooges.length;i++){&nbsp; &nbsp; stooges[i].placeCode === 'sh'?stooges[i].placeCode = '沪': stooges[i].placeCode = '深'}一个循环就搞定 为啥用库来?
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript