Skip to content

Commit 2035e46

Browse files
committed
minor
1 parent b9714f1 commit 2035e46

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

1-js/02-first-steps/14-function-basics/article.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ showMessage();
101101
alert( userName ); // *!*Bob*/!*, the value was modified by the function
102102
```
103103

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.
105105

106106
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:
107107

@@ -128,7 +128,7 @@ Variables declared outside of any function, such as the outer `userName` in the
128128
129129
Global variables are visible from any function (unless shadowed by locals).
130130
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.
132132
```
133133

134134
## Parameters
@@ -376,7 +376,7 @@ A few examples of breaking this rule:
376376
- `createForm` -- would be bad if it modifies the document, adding a form to it (should only create it and return).
377377
- `checkPermission` -- would be bad if it displays the `access granted/denied` message (should only perform the check and return the result).
378378

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.
380380
```
381381

382382
```smart header="Ultrashort function names"

9-regular-expressions/04-regexp-escaping/article.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let reg = new RegExp("\d\.\d");
6161
alert( "Chapter 5.1".match(reg) ); // null
6262
```
6363

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?
6565

6666
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.
6767

@@ -77,7 +77,7 @@ The quotes "consume" backslashes and interpret them, for instance:
7777
- `\u1234` -- becomes the Unicode character with such code,
7878
- ...And when there's no special meaning: like `\d` or `\z`, then the backslash is simply removed.
7979

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!
8181

8282
To fix it, we need to double backslashes, because quotes turn `\\` into `\`:
8383

0 commit comments

Comments
 (0)