Do not use the browser console for volume experiments. Different browser consoles run your code differently.
If you run this code in exactly the same way as in a regular environment, correctly, you will get a ReferenceError from the first line of console.log(b) :
function a() { b = 14; } console.log(b);
Even in free mode, trying to read the value of an undeclared identifier is a ReferenceError .
If we remove the original console.log , we will be in an area that varies depending on the free and strict mode:
With the horror of implicit globals, 1 in free mode, assigning an undeclared identifier creates a global variable.
Vs.
... how it should be.
1 This post is on my anemic little blog.
source share