ES6/JavaScript - declaring variables without let/const
By omitting let
, const
, or var
in non-strict mode, you create a property on the global object.
By the way, babel
will add "use strict";
by default. So you will get a error with babel
.
You can try it here: https://babeljs.io/repl/
In this case, x becomes a global variable. Try to avoid this as global variables can be hard on the browser.