forEach
// for each
devices.forEach(function (device){
console.log(device);
})
// jQuery
$.each(json, function(key, device) {
console.log(key + '> ' + device);
});
// konventionell
for (var d = 0; d < devices.length; d++) {
console.log(devices[d]);
}
// for each
devices.forEach(function (device){
console.log(device);
})
// jQuery
$.each(json, function(key, device) {
console.log(key + '> ' + device);
});
// konventionell
for (var d = 0; d < devices.length; d++) {
console.log(devices[d]);
}
// for each devices.forEach(function (device){ console.log(device); }) // jQuery $.each(json, function(key, device) { console.log(key + '> ' + device); }); // konventionell for (var d = 0; d < devices.length; d++) { console.log(devices[d]); }
! Ein forEach ist wesentlich unperformaneter als die konventionelle for-Schleife.
Bsp 2
! Achtung
Bsp 3
! Achtung