标签:var [] for console script ons IV 关联数组 obj
var arr1 = [111,222,333,444]; var arr2 = [‘张三‘,‘李四‘,‘王五‘,‘刘琦‘]; var objArr = []; for(var i = 0; i < arr1.length; i++){ var obj = {}; obj.id = arr1[i]; obj.name = arr2[i]; objArr.push(obj); } console.log(objArr); /*[ {id: 1, name: "张三"}, {id: 2, name: "李四"}, {id: 3, name: "王五"}, {id: 4, name: "刘琦"} ]*/
标签:var [] for console script ons IV 关联数组 obj
原文地址:https://www.cnblogs.com/harlem/p/9115959.html