JavaScript Performance Tricks

Performance Hints
var Statements
Use var statements when possible. Not only is it good programming practice, it can speed up your code by allowing the compiler to generate special code to access the variables. For example, you could rewrite
function sum(a) {
result = 0;
for (i=0; i < [...]