Strict mode

Strict mode in Javascript is recommended.  You get it by putting this line near the start of the script:*

'use strict';

This tells the interpreter to give warnings about code to be deprecated, force you to declare variables, and some other good things.  The way you'll notice it is it'll make your script crash on undeclared variables.  To declare them, use var:

function myFunc (arg1)
{
   var localVar = ['something','or','another'];
   ...
}


*Or inside a function.  You should use it for all your code, but if your code has to work with someone else's, you might not want to force strict mode on them.  Here's how to put it in a function:

function myFunc (arg1)
{
   'use strict';

   var localVar = ['something','or','another'];
   ...
}