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/03-code-quality/01-debugging-chrome/article.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Before writing more complex code, let's talk about debugging.
4
4
5
-
[Debugging](https://en.wikipedia.org/wiki/Debugging) is the process of finding and fixing errors within a script. All modern browsers and most other environments support debugging tools -- a special UI in developer tools that enable debugging much easier. It also allows to trace the code step by step to see what exactly is going on.
5
+
[Debugging](https://en.wikipedia.org/wiki/Debugging) is the process of finding and fixing errors within a script. All modern browsers and most other environments support debugging tools -- a special UI in developer tools that makes debugging much easier. It also allows to trace the code step by step to see what exactly is going on.
6
6
7
7
We'll be using Chrome here, because it has enough features, most other browsers have a similar process`.
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/03-symbol/article.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ alert(id); // TypeError: Cannot convert a Symbol value to a string
50
50
*/!*
51
51
```
52
52
53
-
That's a "language guard" against messing up, because strings and symbols are fundamentally different and should not occasionally convert one into another.
53
+
That's a "language guard" against messing up, because strings and symbols are fundamentally different and should not accidentally convert one into another.
54
54
55
55
If we really want to show a symbol, we need to explicitly call `.toString()` on it, like here:
56
56
```js run
@@ -72,7 +72,7 @@ alert(id.description); // id
72
72
73
73
## "Hidden" properties
74
74
75
-
Symbols allow us to create "hidden" properties of an object, that no other part of code can occasionally access or overwrite.
75
+
Symbols allow us to create "hidden" properties of an object, that no other part of code can accidentally access or overwrite.
76
76
77
77
For instance, if we're working with `user` objects, that belong to a third-party code. We'd like to add identifiers to them.
78
78
@@ -92,7 +92,7 @@ alert( user[id] ); // we can access the data using the symbol as the key
92
92
93
93
What's the benefit of using `Symbol("id")` over a string `"id"`?
94
94
95
-
As `user` objects belongs to another code, and that code also works with them, we shouldn't just add any fields to it. That's unsafe. But a symbol cannot be accessed occasionally, the third-party code probably won't even see it, so it's probably all right to do.
95
+
As `user` objects belongs to another code, and that code also works with them, we shouldn't just add any fields to it. That's unsafe. But a symbol cannot be accessed accidentally, the third-party code probably won't even see it, so it's probably all right to do.
96
96
97
97
Also, imagine that another script wants to have its own identifier inside `user`, for its own purposes. That may be another JavaScript library, so that the scripts are completely unaware of each other.
98
98
@@ -284,7 +284,7 @@ Symbols are always different values, even if they have the same name. If we want
284
284
Symbols have two main use cases:
285
285
286
286
1. "Hidden" object properties.
287
-
If we want to add a property into an object that "belongs" to another script or a library, we can create a symbol and use it as a property key. A symbolic property does not appear in `for..in`, so it won't be occasionally processed together with other properties. Also it won't be accessed directly, because another script does not have our symbol. So the property will be protected from occasional use or overwrite.
287
+
If we want to add a property into an object that "belongs" to another script or a library, we can create a symbol and use it as a property key. A symbolic property does not appear in `for..in`, so it won't be accidentally processed together with other properties. Also it won't be accessed directly, because another script does not have our symbol. So the property will be protected from accidental use or overwrite.
288
288
289
289
So we can "covertly" hide something into objects that we need, but others should not see, using symbolic properties.
Copy file name to clipboardExpand all lines: 1-js/05-data-types/05-array-methods/article.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -124,7 +124,7 @@ arr.slice(start, end)
124
124
125
125
It returns a new array copying to it all items from index `start` to `end` (not including `end`). Both `start` and `end` can be negative, in that case position from array end is assumed.
126
126
127
-
It's similar to a string method `str.slice`, but instead of substringss it makes subarrays.
127
+
It's similar to a string method `str.slice`, but instead of substrings it makes subarrays.
Copy file name to clipboardExpand all lines: 1-js/05-data-types/12-json/article.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -286,13 +286,13 @@ The first call is special. It is made using a special "wrapper object": `{"": me
286
286
The idea is to provide as much power for `replacer` as possible: it has a chance to analyze and replace/skip even the whole object if necessary.
287
287
288
288
289
-
## Formatting: spacer
289
+
## Formatting: space
290
290
291
-
The third argument of `JSON.stringify(value, replacer, spaces)` is the number of spaces to use for pretty formatting.
291
+
The third argument of `JSON.stringify(value, replacer, space)` is the number of spaces to use for pretty formatting.
292
292
293
-
Previously, all stringified objects had no indents and extra spaces. That's fine if we want to send an object over a network. The `spacer` argument is used exclusively for a nice output.
293
+
Previously, all stringified objects had no indents and extra spaces. That's fine if we want to send an object over a network. The `space` argument is used exclusively for a nice output.
294
294
295
-
Here `spacer = 2` tells JavaScript to show nested objects on multiple lines, with indentation of 2 spaces inside an object:
295
+
Here `space = 2` tells JavaScript to show nested objects on multiple lines, with indentation of 2 spaces inside an object:
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/01-recursion/article.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -337,7 +337,7 @@ As we can see, when our function gets a department to sum, there are two possibl
337
337
338
338
The 1st case is the base of recursion, the trivial case, when we get an array.
339
339
340
-
The 2nd case when we gen an object is the recursive step. A complex task is split into subtasks for smaller departments. They may in turn split again, but sooner or later the split will finish at (1).
340
+
The 2nd case when we get an object is the recursive step. A complex task is split into subtasks for smaller departments. They may in turn split again, but sooner or later the split will finish at (1).
341
341
342
342
The algorithm is probably even easier to read from the code:
0 commit comments