JS Test: Closures

Last modified by Sergiu Dumitriu on 2018/10/10 17:05

Task: What does the following code print? Why?

var outer = function(n, f) {
  f = f || function() {
    console.log(n);
  }
  f();
 return f;
}

var inner = outer(42);
outer(47, inner);