Do you know what will be the output of this code?
JavaScript
function f() {
y = 10;
}
f();
console.log(y);
Show answer and explanation
The answer is 10.
Without var, let or const, the assignment creates a property on the global object. That’s an accidental global.
In strict mode (and in modules and classes) the same code throws ReferenceError: y is not defined.