+ 1
Why the value of 'i' is 2, when there is (i<=1)? JS
2 Réponses
+ 6
function sum(i){
return ++i;
}
for(var i=0;i<=1;i++){}; //when i<=1 , 2<=1 looo stops so i=2;
document.write(sum(i)) // calling sum() with passing i=2 and get return 3 , but it does not modify passed i value so i value remains 2
document.write(i) // prints 2
+ 2
Understand. Thanks