function show() {
return value;
}
let value = 1000
console.log(show());
I guess let is the local variable but I don't understand why this coding returns 1000
I thought an message would appear
value is not defined
function show() {
return value;
}
let value = 1000
console.log(show());
I guess let is the local variable but I don't understand why this coding returns 1000
I thought an message would appear
value is not defined
The problem here, is that the variable is declared in the global scope, so regardless of using let it becomes global.
You can use let insisde a block, and that binding then will be visible only inside the block.
See this for further info: https://www.w3schools.com/js/js_let.asp