数组:[“前端开发”, “移动开发”, “销售”];
原图:
转换成的数组键值对形式:
代码如下:
let munm =["前端开发", "移动开发", "销售"];
let oarr = []; //建立空数组装数组键值对
for (let i = 0; i <= munm.length-1; i++) {
console.log(i, munm[i])
let job = {};
job["id"] = i;
job["jobs_name"] = munm[i];
oarr.push(job)
};
//得到全部结果
console.log(oarr, '///');//转换成的数组键值对形式
简单记录一下!方便查看,少走弯路!!!