You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a long time JavaScript was evolving without compatibility issues. New features were added to the language, but the old functionality did not change.
3
+
For a long time, JavaScript evolved without compatibility issues. New features were added to the language while old functionality didn't change.
4
4
5
-
That had the benefit of never breaking existing code. But the downside was that any mistake or an imperfect decision made by JavaScript creators got stuck in the language forever.
5
+
That had the benefit of never breaking existing code. But the downside was that any mistake or an imperfect decision made by JavaScript's creators got stuck in the language forever.
6
6
7
-
It had been so until 2009 when ECMAScript 5 (ES5) appeared. It added new features to the language and modified some of the existing ones. To keep the old code working, most modifications are off by default. One needs to enable them explicitly with a special directive `"use strict"`.
7
+
This was the case until 2009 when ECMAScript 5 (ES5) appeared. It added new features to the language and modified some of the existing ones. To keep the old code working, most modifications are off by default. You need to explicitly enable them with a special directive:`"use strict"`.
8
8
9
9
## "use strict"
10
10
11
-
The directive looks like a string: `"use strict"` or `'use strict'`. When it is located on the top of the script, then the whole script works the "modern" way.
11
+
The directive looks like a string: `"use strict"` or `'use strict'`. When it is located at the top of a script, the whole script works the "modern" way.
12
12
13
-
For example
13
+
For example:
14
14
15
15
```js
16
16
"use strict";
@@ -21,17 +21,17 @@ For example
21
21
22
22
We will learn functions (a way to group commands) soon.
23
23
24
-
Looking ahead let's just note that `"use strict"` can be put at the start of a function (most kinds of functions) instead of the whole script. Then strict mode is enabled in that function only. But usually people use it for the whole script.
24
+
Looking ahead, let's just note that `"use strict"` can be put at the start of most kinds of functions instead of the whole script. Doing that enables strict mode in that function only. But usually, people use it for the whole script.
25
25
26
26
27
27
````warn header="Ensure that \"use strict\" is at the top"
28
-
Please make sure that `"use strict"` is on the top of the script, otherwise the strict mode may not be enabled.
28
+
Please make sure that `"use strict"` is at the top of your scripts, otherwise strict mode may not be enabled.
29
29
30
-
There is no strict mode here:
30
+
Strict mode isn't enabled here:
31
31
32
32
```js no-strict
33
33
alert("some code");
34
-
// "use strict" below is ignored, must be on the top
34
+
// "use strict" below is ignored--it must be at the top
35
35
36
36
"use strict";
37
37
@@ -42,20 +42,20 @@ Only comments may appear above `"use strict"`.
42
42
````
43
43
44
44
```warn header="There's no way to cancel `use strict`"
45
-
There is no directive `"no use strict"`or alike, that would return the old behavior.
45
+
There is no directive like `"no use strict"` that reverts the engine to old behavior.
46
46
47
-
Once we enter the strict mode, there's no return.
47
+
Once we enter strict mode, there's no return.
48
48
```
49
49
50
50
## Always "use strict"
51
51
52
-
The differences of `"use strict"` versus the "default" mode are still to be covered.
52
+
We have yet to cover the differences between strict mode and the "default" mode.
53
53
54
-
In the next chapters, as we learn language features, we'll make notes about the differences of the strict and default mode. Luckily, there are not so many. And they actually make our life better.
54
+
In the next chapters, as we learn language features, we'll note the differences between the strict and default modes. Luckily, there aren't many and they actually make our lives better.
55
55
56
-
At this point in time it's enough to know about it in general:
56
+
For now, it's enough to know about it in general:
57
57
58
-
1. The `"use strict"` directive switches the engine to the "modern" mode, changing the behavior of some built-in features. We'll see the details as we study.
59
-
2. The strict mode is enabled by `"use strict"` at the top. Also there are several language features like "classes" and "modules" that enable strict mode automatically.
60
-
3. The strict mode is supported by all modern browsers.
61
-
4. It's always recommended to start scripts with `"use strict"`. All examples in this tutorial assume so, unless (very rarely) specified otherwise.
58
+
1. The `"use strict"` directive switches the engine to the "modern" mode, changing the behavior of some built-in features. We'll see the details later in the tutorial.
59
+
2. Strict mode is enabled by placing `"use strict"` at the top of a script or function. Several language features, like "classes" and "modules", enable strict mode automatically.
60
+
3. Strict mode is supported by all modern browsers.
61
+
4. We recommended always starting scripts with `"use strict"`. All examples in this tutorial assume strict mode unless (very rarely) specified otherwise.
0 commit comments