码迷,mamicode.com
首页 > Web开发 > 详细

js var 以及 let 的差异

时间:2019-04-25 01:24:22      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:find   list   log   false   als   oar   turn   bsp   lse   

 

例子

window.checklist=[{"boardname":"motor_board","cur":"1.0.0","new":"1.0.1"},{"boardname":"power_board","cur":"1.0.0","new":"1.0.1"},{"boardname":"imu_board","cur":"1.0.0","new":"1.0.1"},{"boardname":"sensor_board","cur":"1.0.0","new":"1.0.1"}]

board_list={"imu_board":[1,2,11,12,21,22,31,32],"sensor_board":[1,2,11,12,21,22,31,32],"power_board":[1,2,11,12,21,22,31,32],"motor_board":[1,2,11,12,21,22,31,32]}

findsuccess=function(list){
    for(i in list){
        if(list[i]==32){
            return true
        }
    }
    return false
}
for (let i = 0;i < 4;i++){
    x=board_list[window.checklist[i].boardname]
    console.log(x)
    console.log(findsuccess(x))
}

例子

window.checklist=[{"boardname":"motor_board","cur":"1.0.0","new":"1.0.1"},{"boardname":"power_board","cur":"1.0.0","new":"1.0.1"},{"boardname":"imu_board","cur":"1.0.0","new":"1.0.1"},{"boardname":"sensor_board","cur":"1.0.0","new":"1.0.1"}]

board_list={"imu_board":[1,2,11,12,21,22,31,32],"sensor_board":[1,2,11,12,21,22,31,32],"power_board":[1,2,11,12,21,22,31,32],"motor_board":[1,2,11,12,21,22,31,32]}

findsuccess=function(list){
    for(i in list){
        if(list[i]==32){
            return true
        }
    }
    return false
}

for (var i = 0; i < 4; i++) {
    x=board_list[window.checklist[i].boardname]
    console.log(x)
    console.log(findsuccess(x))
}

 

js var 以及 let 的差异

标签:find   list   log   false   als   oar   turn   bsp   lse   

原文地址:https://www.cnblogs.com/sea-stream/p/10765784.html

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