数组1、
for (const i in declareItems) {
if (declareItems.hasOwnProperty(i)) {
const index = i;
const declareItem = declareItems[i];
}
}
数组2、
for (const item of declareItems) {
contst declareItem = item;
}
数值3、
for (let i = 0; i < declareItems.length; i++) {
const index = i;
const declareItem = declareItems[i];
}
字典1、
var dic={A:"AA",B:"BB",C:"CC"}
dic["D"]="DD";
var temp=dic["D"];
for (var key in dic) { //字典in的关键字是key,数值in的关键字是index
var item = dic[key];
console.log(item); //AA,BB,CC,DD
}