Question: Learning JS here, I run JSLint on this code:

```
/*jslint devel: true*/

function Animal(n) {
    "use strict";
    this.name = n;
    this.prop = "a";
}

var a = new Animal("duppa");

for (v in a) {
    if (a.hasOwnProperty(v)) {
        console.log("property:" + v);
    }
}

```

I get:

```
jslint:test2.js:11:6:'v' was used before it was defined.
jslint:test2.js:11:8:Cannot read property "kind" from undefined

jslint: ignored 0 errors.

```

It obviously complains that I did not declare `v` up front:

```
/*jslint devel: true*/

function Animal(n) {
    "use strict";
    this.name = n;
    this.prop = "a";
}

var a = new Animal("duppa");

var v;
for (v in a) {
    if (a.hasOwnProperty(v)) {
        console.log("property:" + v);
    }
}

```

This shuts JSLint up, but is it really necessary? In general I try to follow good conventions but is this one really necessary in JS? E.g. Python lives happily without such stuff (`for x in range(10)...` etc).

Answer: 
There are 10 types of people in the world. Those who understand why you declare variables in javascript and those who have regular sex. (**Just smile**)

You must understand that every function have their own scope and you must use this scope. If you don't use declaration inside your function you change the global state, and it affects of course on many things.

So use **var** and don't create global variables !!!
As far as my understanding goes, if you use a variable without declaring it within a function scope, it gets declared in the global scope, which isnt a best practice. You will soon cloud your global scope with variables.

```
//This creates a global variable
function not_a_best_practice(){
    a=10;
}

//This creates a local variable
function not_bad(){
    var a=20;
}

```

This answer may throw more light on the discussion at hand:
[What is the scope of variables in JavaScript?](https://stackoverflow.com/questions/500431/javascript-variable-scope)