params escopo em javascript

var x = 1;
 
function foo(y = function() { return x; }) { // capture `x`
  var x = 2;
  return y();
}
 
foo(); // correctly 1, not 2
Funny Name