First, what you're seeing is legacy behavior. Assignment to an undeclared symbol traditionally meant, implicitly, that a global symbol should be created (declared) and set to the given value. Thus
x = 1;
when x has not been declared was taken to be an implicit instantiation of a global symbol.
The mention of an undeclared symbol, as in:
x;
is an error because the symbol is undeclared.
In modern JavaScript, and when "strict" mode is in force because of a
"use strict";
statement (or because of other influences, as may be the case with Node.js code), the implicit creation of global symbols is also erroneous.
Generally, implicit global symbol instantiation is considered a bad idea. Global symbols in browser JavaScript are quite problematic because the global namespace is so horribly polluted. Thankfully, it's easy to wrap code in a function scope to create a "safe space" for symbols without fear of the browser imposing weird global names.