Array: ["Frontend Development", "Mobile Development", "Sales"];
Original image:
Converted array key-value pair form:
the code is as follows:
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, '///');//转换成的数组键值对形式
Simply record it! Easy to check, less detours! ! !