I'm using MDN guide to learn JS and I use scratchpad to try some examples.
If I write
console.log('The value of b is ' + b);
var b;
Why does console.log say "The value of b is -1" ?! It should be undefined
I'm using MDN guide to learn JS and I use scratchpad to try some examples.
If I write
console.log('The value of b is ' + b);
var b;
Why does console.log say "The value of b is -1" ?! It should be undefined
Copyright © 2021 Jogjafile Inc.
Probably you defined the
var bbefore with the value-1.If you try the above code, you will see that, if the variable is already instantiated and if you declare again the variable without set any value to them, the variable it will not be instantiated.