var x = "hi!";
request(url, function(error, response, body) {
console.log(x); //prints "hi!"
});
If I remove the line console.log(x)
and replace it with console.log('hello!')
and put a breakpoint on that line in the WebStorm, and if I try to evaluate x
, it says "ReferenceError: x is not defined".
Why is that? Is it just how WebStorm works or does JavaScript have some sort of a pre-processor that only includes variables being used in a function, in it's closure?