diff --git a/1-js/04-object-basics/02-garbage-collection/article.md b/1-js/04-object-basics/02-garbage-collection/article.md index 913e1e8c..571d9f11 100644 --- a/1-js/04-object-basics/02-garbage-collection/article.md +++ b/1-js/04-object-basics/02-garbage-collection/article.md @@ -175,7 +175,7 @@ Then their references are marked: ![](garbage-collection-3.png) -...And their refences, while possible: +...And their references, while possible: ![](garbage-collection-4.png) diff --git a/1-js/05-data-types/04-array/article.md b/1-js/05-data-types/04-array/article.md index d9093aa4..635205dd 100644 --- a/1-js/05-data-types/04-array/article.md +++ b/1-js/05-data-types/04-array/article.md @@ -421,7 +421,7 @@ alert( [1] + 1 ); // "11" alert( [1,2] + 1 ); // "1,21" ``` -Arrays do not have `Symbol.toPrimitive`, neither a viable `valueOf`, they implement only `toString` conversion, so here `[]` becomes an empty string, `[1]` becomes `"1"` and `[1,2]` becomes `"1,2". +Arrays do not have `Symbol.toPrimitive`, neither a viable `valueOf`, they implement only `toString` conversion, so here `[]` becomes an empty string, `[1]` becomes `"1"` and `[1,2]` becomes `"1,2"`. When the binary plus `"+"` operator adds something to a string, it converts it to a string as well, so the next step looks like this: diff --git a/1-js/05-data-types/05-array-methods/article.md b/1-js/05-data-types/05-array-methods/article.md index 561c8687..26163457 100644 --- a/1-js/05-data-types/05-array-methods/article.md +++ b/1-js/05-data-types/05-array-methods/article.md @@ -100,7 +100,7 @@ alert( arr ); // "I", "study", "complex", "language", "JavaScript" ``` ````smart header="Negative indexes allowed" -Here and in other array methods, negative indexes are allowed. The specify the position from the end of the array, like here: +Here and in other array methods, negative indexes are allowed. They specify the position from the end of the array, like here: ```js run let arr = [1, 2, 5] @@ -382,7 +382,7 @@ alert(arr); // *!*1, 2, 15*/!* Now it works as intended. -Let's step aside and thing what's happening. The `arr` can be array of anything, right? It may contain numbers or strings or html elements or whatever. We have a set of *something*. To sort it, we need an *ordering function* that knows how to compare its elements. The default is a string order. +Let's step aside and think what's happening. The `arr` can be array of anything, right? It may contain numbers or strings or html elements or whatever. We have a set of *something*. To sort it, we need an *ordering function* that knows how to compare its elements. The default is a string order. The `arr.sort(fn)` method has a built-in implementation of sorting algorithm. We don't need to care how it exactly works (an optimized [quicksort](https://en.wikipedia.org/wiki/Quicksort) most of the time). It will walk the array, compare its elements using the provided function and reorder them, all we need is to provide the `fn` which does the comparison.