码迷,mamicode.com
首页 > 其他好文 > 详细

常用for循环和for in 以及for of 的区别

时间:2017-06-28 13:05:09      阅读:345      评论:0      收藏:0      [点我收藏+]

标签:运算   logs   pos   常用   res   nbsp   ons   url   func   

用Es6对象扩展运算符(…)与rest运算符说明

function test(first,...a){
    for(let val=0; val<a.length;val++){
        console.log(val+‘ ‘+‘常用的 for循环‘) // 0-6 便利出下标
    }

    for(let val in a){
        console.log(val+‘ ‘+ ‘for in  0-6 便利出下标‘) // 0-6 便利出下标
    }

    for(let val of a){
        console.log(val+‘ ‘+ ‘for of 2-8 便利值‘) //2-8 便利值
    }
}
test(1,2,3,4,5,6,7,8)

 

常用for循环和for in 以及for of 的区别

标签:运算   logs   pos   常用   res   nbsp   ons   url   func   

原文地址:http://www.cnblogs.com/model-zachary/p/7088977.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!