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
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/14-function-basics/article.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ showMessage();
101
101
alert( userName ); // *!*Bob*/!*, the value was modified by the function
102
102
```
103
103
104
-
The outer variable is only used if there's no local one. So an occasional modification may happen if we forget `let`.
104
+
The outer variable is only used if there's no local one.
105
105
106
106
If a same-named variable is declared inside the function then it *shadows* the outer one. For instance, in the code below the function uses the local `userName`. The outer one is ignored:
107
107
@@ -128,7 +128,7 @@ Variables declared outside of any function, such as the outer `userName` in the
128
128
129
129
Global variables are visible from any function (unless shadowed by locals).
130
130
131
-
Usually, a function declares all variables specific to its task. Global variables only store project-level data, and it's important that these variables are accessible from anywhere. Modern code has few or no globals. Most variables reside in their functions.
131
+
It's a good practice to minimize the use of global variables. Modern code has few or no globals. Most variables reside in their functions. Sometimes though, they can be useful to store project-level data.
132
132
```
133
133
134
134
## Parameters
@@ -376,7 +376,7 @@ A few examples of breaking this rule:
376
376
- `createForm` -- would be bad if it modifies the document, adding a form to it (should only create it and return).
377
377
- `checkPermission` -- would be bad if it displays the `access granted/denied` message (should only perform the check and return the result).
378
378
379
-
These examples assume common meanings of prefixes. What they mean for you is determined by you and your team. Maybe it's pretty normal for your code to behave differently. But you should have a firm understanding of what a prefix means, what a prefixed function can and cannot do. All same-prefixed functions should obey the rules. And the team should share the knowledge.
379
+
These examples assume common meanings of prefixes. You and your team are free to agree on other meanings, but usually they're not much different. In any case, you should have a firm understanding of what a prefix means, what a prefixed function can and cannot do. All same-prefixed functions should obey the rules. And the team should share the knowledge.
Copy file name to clipboardExpand all lines: 9-regular-expressions/04-regexp-escaping/article.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ let reg = new RegExp("\d\.\d");
61
61
alert( "Chapter 5.1".match(reg) ); // null
62
62
```
63
63
64
-
It worked with `pattern:/\d\.\d/`, but with `new RegExp("\d\.\d")` it doesn't, why?
64
+
The search worked with `pattern:/\d\.\d/`, but with `new RegExp("\d\.\d")` it doesn't work, why?
65
65
66
66
The reason is that backslashes are "consumed" by a string. Remember, regular strings have their own special characters like `\n`, and a backslash is used for escaping.
67
67
@@ -77,7 +77,7 @@ The quotes "consume" backslashes and interpret them, for instance:
77
77
-`\u1234` -- becomes the Unicode character with such code,
78
78
- ...And when there's no special meaning: like `\d` or `\z`, then the backslash is simply removed.
79
79
80
-
So the call to `new RegExp` gets a string without backslashes. That's why it doesn't work!
80
+
So the call to `new RegExp` gets a string without backslashes. That's why the search doesn't work!
81
81
82
82
To fix it, we need to double backslashes, because quotes turn `\\` into `\`:
0 commit comments