Jighead
11/17/2017 - 4:00 PM

closure.js

// a basic closure example
function closure(base){
  var pad = 10;
  return function(num) {
    // this inner function has access to base variable
    console.log(base + pad + num);
  }
}
var test = closure(2);
test(1);
closure(2)(3);