7 ms·
I didn't notice this quirk about global vars either, and indeed if you copypaste into jsfiddle both console.logs are actually undefined. TIL if you use strict
by squirtle24 4y ago
I didn't notice this quirk about global vars either, and indeed if you copypaste into jsfiddle both console.logs are actually undefined.
TIL if you use strict mode, undefined vars do not become global.
- j16sdiz 4y agoThe question have error. You need to call `foo()` before the first `console.log` to get that behavior. function foo() { let a = b = 0 a++ return a } foo() // <------ INSERT THIS console.log(typeof a) console.log(typeof b)