标签:pre 打印 span cti col function style fun color
var formArr = [ {name: "Name", value: "111"}, {name: "Price", value: "2"}, {name: "ProducingArea", value: "3"}, {name: "ShelfLife", value: "44"}, {name: "Stock", value: "5"} ]; var obj={ }; //map循环方式 formArr.map(function (e, item) { console.log(e.name); obj[e.name] = e.value; }); //$.each循环方式 $.each(formArr, function (item,e) { console.log(e.name); obj[e.name] = e.value; }) //for in 循环方式 for (var item in formArr){ obj[formArr[item].name] = formArr[item].value; }; 结果打印:obj = {Name: "2", Price: "3", ProducingArea: "4", ShelfLife: "5", Stock: "6"}
标签:pre 打印 span cti col function style fun color
原文地址:https://www.cnblogs.com/yangxuanxuan/p/13217358.html