需求是将b根据a的值替换对象中的key值 let a = ["code","name","date","font"]; let b = [{1:2,2:3,3:4},{1:2,2:3,3:4},{1:2,2:3,3:4}]; //[{'code':2,'name':3,'date':4},{'code':2,'name':3,'date':4},{'code':2,'name':3,'date':4}]; let c = b.
<script type="text/javascript"> getJson('age'); function getJson(key){ var jsonObj={"name":"傅红雪","age":"24","profession":"刺客"}; //1.使用eval方法 var eValue=eval('jsonObj.'+key); alert
功能: var fruitArry=[{name:'durian'},{name:'peach'},{name:'banana'},{name:'pitaya'},{name:'apple'},{name:'cherry'}]; var fruit={'banana':'香蕉','peach':'桃子','durian':'榴莲','pitaya':'火龙果'}; 将 fruitArry 中 name 的值根据 fruit 的 key 值进行替换:如果 fruitArry 的