Javascript, For loop: returned 'i' value is different from that is stored -


in loop alert(i) alerts 12,and firebug displays 10 end result.

 for(var i=0;i<=10;i=i+2){       document.write=i;     }      alert(i); 

i gets incremented after every iteration of loop. when fails condition <= 10 loop breaks:

0 => loop gets executed, incremented 2 2 => loop gets executed, incremented 2 4 => loop gets executed, incremented 2 6 => loop gets executed, incremented 2 8 => loop gets executed, incremented 2 10 => loop gets executed, incremented 2 12 => loop breaks => remains @ 12 

Comments

Popular posts from this blog

command line - Use qwinsta in PowerShell ISE -

java - Incorrect order of records in M-M relationship in hibernate -

php - I want to create a website for polls/survey like this http://www.poll-maker.com/ -