var variableName = variableValue;
var keyword should be used whenever you create a new variable and it should be particularly used when variables are being declared inside a function.
If, when declaring a variable inside a function, use of var is omitted then such a variable becomes global in scope by default. Yes, you read it right – not using var when declaring a variable will make that variable global!
Once a variable becomes global, its kind of available to all and modifiable from any source. Such a thing can have terrible consequences and can adversely affect results expected from your script.
Such a stuff also makes a script difficult to debug, particularly so, if the script is too large.