Variable Definition

jQuery

Variable Definition

Variables can be defined in one statement instead of several.

1
2
3
4
5
6
7
8
9
                          
// old & busted
var test = 1;
var test2 = function() { ... };
var test3 = test2( test );
// new hotness
var test = 1,
test2 = function() { ... },
test3 = test2( test );

In self-executing functions, variable definition can be skipped all together.

1
2
3
                          
(function( foo, bar ) {
// ...
})( 1, 2 );