Answers for "params scope in javascript"

0

params scope in javascript

var x = 1;
 
function foo(y = function() { return x; }) { // capture `x`
  var x = 2;
  return y();
}
 
foo(); // correctly 1, not 2
Posted by: Guest on July-15-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language