js var 以及 let 的差异
例子
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)) }