What's the output?
let greeting;
greetign = {}; // Typo!
console.log(greetign);You missed this one before
It logs the object, because we just created an empty object on the global object! When we mistyped greeting as greetign, the JS interpreter actually saw this as:
global.greetign = {}in Node.jswindow.greetign = {},frames.greetign = {}andself.greetignin browsers.self.greetignin web workers.globalThis.greetignin all environments.
In order to avoid this, we can use "use strict". This makes sure that you have declared a variable before setting it equal to anything.
Question 9 · see the original (opens in a new tab)
or press Enter