NoNameCracksInc

Dragon Closure

Aug 30th, 2015
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. This is closure which I called dragon.It's bypassing all disadvantages of global variables and allows you to store and fetch two dimensional arrays.
  2.  
  3. var dragon = (function(){var arr=[];for(var i=0;i<=5;i++){arr[i]=[];}return function(a,b){if(b%1 === 0){return arr[a][b];}else if(typeof b !== 'undefined'){arr[a].push(b);}else{return arr[a];}}})();
Advertisement
Add Comment
Please, Sign In to add comment