标签:权威指南 script 属性 ons div style span 区别 遍历
1、for/each和for/in
区别:for/each并不是遍历对象的属性,而是遍历属性的值
//遍历对象 let o = {one:1, two:2, three:3} for(let p in o) console.log(p) //‘one‘ , ‘two‘, ‘three‘ for each(let v in o) console.log(v) // 1,2,3 //遍历数组 a = [‘one‘, ‘two‘, ‘three‘] for(let p in a) console.log(p) // 0 , 1 , 2 for each(let v in a) console.log(v) //‘one‘, ‘two‘, ‘three‘
JavaScript权威指南(JavaScript的子集和扩展)
标签:权威指南 script 属性 ons div style span 区别 遍历
原文地址:https://www.cnblogs.com/jun-web/p/simple-foreach.html