(function () {
  try {
    throw new Error();
  } catch (x) {
    var x = 1;
    var y = 2;
    console.log(x);
  }
  console.log(x);
  console.log(y);
})()why does this code print: 1 undefined 2
Since we are using var to declare both x and y, why is x not accessible outside the catch block but y is.
 
     
    