I am trying to understand new function syntax.
When I declare variable 'value' using let it, I get an error
ReferenceError: value is not defined
but if I use var or without var the output is printed as test. I assume that the 'value' variable is global because it is defined outside.
But why does it work with var but not let although both are global variable?
let value = "test";
function getFunc() {
// value = "test";
let func = new Function('console.log(value)');
return func;
}
getFunc()();