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
1 回答
皈依舞
TA贡献1851条经验 获得超3个赞
for(var i=0;i<stooges.length;i++){
stooges[i].placeCode === 'sh'?stooges[i].placeCode = '沪': stooges[i].placeCode = '深'
}
一个循环就搞定 为啥用库来?
添加回答
举报
0/150
提交
取消