var keyMap = { deviceUid: "id", deviceType: "typeName", deviceCode: "code", deviceName: "name", deviceStatus: "status" }; for (var i = 0; i < data.confList.length; i++) { var obj = data.confList[i]; for
Js代码 <script type="text/javascript"> getJson('age'); function getJson(key){ var jsonObj={"name":"张三","age":"24","profession":"工程师"}; 遍历Json串获取其属性 for(var item in jsonObj){ if(item
//---------for用来遍历数组对象 var i,myArr = ["a","b","c"]; ; i < myArr.length; i++) { console.log(i+":"+myArr[i]); }; //---------for-in 用来遍历非数组对象方法一. var man ={"1":"a","2":"b",&qu
1.标准的for循环遍历数组 //不打印自定义属性和继承属性 var array = [1,2,3]; for (var i = 0; i < array.length; i++) { console.log(array[i]); } 2.for in 遍历对象 不要用for in遍历数组,因为还会打印自定义属性和继承属性 一般常用来遍历非数组的对象并且使用hasOwnProperty()方法去过滤掉原型链上的属性 数组的key是string类型,因为js中一切皆为对象. var array =