daily pastebin goal


a guest Jan 16th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Knowing that we have access to whatever
  2. //the user inputs into our function expression, we then write...  
  3. return function(){    
  4.      var key = JSON.stringify(arguments);
  5.      if (cash[key]){
  6.       return cache[key];
  7.      }
  9.     else{
  10.       //apply() comes in handy here and will simply
  11.       //return the value of the function it calls
  12.       val = func.apply(this, arguments);
  13.       //then we set the value of the function to the key(argument).
  14.       //The next time the function runs,
  15.       //if the argument is the same, we simply return
  16.       //the value without having to have the function execute.
  17.       cash[key] = val;
  18.       return val;
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand