Variable Identifiers
- Naming rules
Examples of valid and invalid names
|
|
|
|
Keywords and Reserved Words
Case Sensitivity
|
|
Strict Mode
Why strict mode was introduced
Benefits
- Removes unreasonable, loose, and unsafe parts of JS syntax, reduces quirky behavior, and keeps code running safely
- Makes the compiler more efficient and code run faster
Usage
Enable strict mode globally
|
|
Enable strict mode inside a function
|
|
Differences between strict mode and normal mode
- In strict mode, you can't implicitly declare and define variables
|
|
- In strict mode, objects can't have duplicate property names
|
|
- You can't call arguments.callee (used for recursion in anonymous functions)
|
|
- The with statement12345678var x,y;(function)(){"use strict";with(Math) { //TypeErrorx = cos(3 * PI) + sin (LN10);Y = tan(14 * E);}})();
Strict mode has other restrictions too
Comments
|
|
