下面 CMS代码网为大家介绍一下数组相关运用
//数组一后面添加数组二
const typesAdd = [{"id": 0,"type": "请选择"}] const typesAdd2 = [{"id": 1,"type": "中国"}] const typesList = typesAdd.concat(typesAdd2);
//获取数组下标
const checkContent2 = [{"id": 0,"type": "请选择"},{"id": 1,"type": "中国"}] const valuesNum = [] for (let i = 0; i < checkContent2.length; i++) { valuesNum.push(i) }
//数组添加定义ids
const valuesList = [] valuesNum.forEach(function (item) { valuesList.push({ ids: item }) });
//两个数组合并
const newsItems = checkContent2.map((item, index) => { return { ...item, ...valuesList[index] }; });
上面是关于“数组相关运用”的详细介绍,想了解更多关于seo教程内容,请继续关注 CMS代码网!