我需要拆分这个字符串并循环遍历结果数组。但是,即使我的结果字符串数组只有 3 个项目,我的循环也会进入无穷大。
我可能遗漏了一些东西,但此时我看不到它。
这是代码:
CustomizeDashboardService.getCustomizedDashboard().then(function (res) {
console.log(res);
var sensors = res.sensor.split(',');
var devices = res.uuid.split(',');;
console.log("CS: S",sensors) // I Can see these 2 arrays have only 3 items each,
console.log("CS: D",devices) // but when it goes into my for loop, it iterates to indefinite
for(i=0;i<devices.length-1;i++){
console.log("girdi") // I see this is logging more than 1000 times
var index = findIndex(devices[i]);
var obj = {
device:self.deviceList[index],
sensor: sensors[i]
}
self.customizedSensors.push(obj);
}
console.log("customized sensors",self.customizedSensors);
})