var, multi-var or anywhere var?

added by JavaScript Kicks
3/25/2015 8:42:00 PM


Anyone familiar with Crockford and jshint will be familiar with the onevar rule - all variables must be declared in a single var statement at the top of the file. function myFunc() { var i, j, date, myVariable; ... } There is logic behind it;- this is what the language is actually doing, so if you write your code like this, no variable hoisting will occur and therefore people reading your code will not have to worry about hoisting and instead concentrate on program function.