标签:log color 对象 pre cti key style index dex
<script>
//for..in..遍历对象,拿到的是对象键名,键名获取用对象[键名]
var a = {
key1 : 1 ,
key2 : 2 ,
key3 : 3
}
for(item in a){
console.log(a[item]);
}
//foreach遍历数组,value表示遍历的值,index表示元素的小标
var a = [
‘1‘,‘2‘,‘3‘
]
a.forEach(function(item,index){
console.log(‘数组的值‘+item);
console.log(‘数组的下标‘+index);
})
</script>
标签:log color 对象 pre cti key style index dex
原文地址:https://www.cnblogs.com/libainian/p/13081657.html