Why you should use var in your for loop control variables


Had a conversation recently about JavaScript and the importance of var for scoping your variables- even in for-loop control variables; This little gotcha still seem’s to get a few devs so thought I would post a fiddle…

http://jsfiddle.net/shawson/gH4KC/5/

  1. #1 by Gareth on August 10, 2012 - 12:47

    Cheers mate, that is really useful!

(will not be published)