//use strict is the first sentence and i have consciously written wrong spelling lenght
"use strict";
var x="dd";
console.log(x.lenght);
It signals to the JS interpreter to activate several protections and amendments to how it evaluates code. It doesn’t check syntax. The JS interpreter itself does check syntax, in that it executes valid JS code. The result of that “syntax check” is this code will not tell you the length of x
, it’s not going to tell you you misspelled length
because you may have added the property lenght
to x
or String
's prototype, what’s written here may be completely valid code.
1 Like