js 把对象存入数组中
var params = []; var info= { "张三" : "21", "李四" : "32", "王五" : "14", "小红" : "31", "小兰" : "24", "王明" : "22", }; for ( var key in info) { var param = {}; param.name= key; param.age= info[key]; params.push(param); } console.log(params); //结果[{name:'张三',age:'21'},{name:'李四',age:'32'},{name:'王五',age:'14'}, // {name:'小红',age:'31'},{name:'小兰',age:'24'},{name:'王明',age:'22'}]
标签:name,age,param,存入,params,数组,var,js From: https://www.cnblogs.com/y593216/p/17928805.html