Limiting Variable Scope using Javascript Closures

by Sasikumar 2014-08-06 16:55:16

Limit the scope of variable using javascript closures
Javascript Example :
// Task 1
(function() {
	var link = $('a');
	var div = $('div');
        // use this link and div which has scope only here
})();

// Task 2
(function() {
	var link = $('a');
	var div = $('div');
        // use this link and div which has scope only here
})();
Both are same variable but they will not affect each other.
1506
like
0
dislike
0
mail
flag

You must LOGIN to add comments