What's the difference between two set of codes, I know what arrow function does but why traditional expression does not work?
Set - 1
loop through all elements
checkboxes.forEach( function (checkbox){
console.log(checkbox);
if( checkbox === this || checkbox === lastChecked)
{
inBetween = !inBetween;
console.log(" start checking them inbetween");
}
if(inBetween)
{
checkbox.checked = true;
}
});
Set - 2
loop through all elements
checkboxes.forEach(checkbox => {
console.log(checkbox);
if (checkbox === this || checkbox === lastChecked) {
inBetween = !inBetween;
console.log('Starting to check them in between!');
}
if (inBetween) {
checkbox.checked = true;
}
});
Aucun commentaire:
Enregistrer un commentaire