OTHER CHANGES
There are several other changes to strict mode of which you need to be aware. The first is the elimination of the with
statement. The with
statement changes how identifiers are resolved and has been removed from strict mode as a simplification. An attempt to use with
in strict mode results in a syntax error.
// Use of the with statement
// Non-strict mode: Allowed
// Strict mode: Throws a syntax error
with(location) {
alert(href);
}
Strict mode also eliminates the octal literal from JavaScript. Octal literals begin with a zero and have traditionally been the source of many errors. An octal literal is now considered invalid syntax in strict mode.
// Use of octal literal
// Non-strict mode: value is 8.
// Strict mode: throws a syntax error.
let value = 010;
ECMAScript 5 changed parseInt()
for nonstrict mode, where octal literals are now considered decimal literals with a leading zero. For example:
// Use of octal literal in parseInt()
// Non-strict mode: value is 8
...