Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
f723253
transpiler def
joaquinelio Mar 28, 2021
3d88d33
Update article.md
ZYinMD Jun 13, 2021
2dce19e
"inserts into" instead of "appends to"
joaquinelio Jun 16, 2021
497ca99
Update article.md
joaquinelio Jun 16, 2021
9680c67
Merge pull request #2633 from joaquinelio/patch-4
iliakan Jun 16, 2021
cd466c5
Unnecessary escape characters in cookie.js
NNboru Jun 17, 2021
8c910b4
Update article.md
joaquinelio Jun 18, 2021
8cf2d51
Update article.md
joaquinelio Jun 18, 2021
0c41930
Update article.md
joaquinelio Jun 18, 2021
263f57e
Update article.md
joaquinelio Jun 18, 2021
492f506
Merge pull request #2555 from joaquinelio/patch-6
iliakan Jun 18, 2021
a6dfbb7
minor fixes
iliakan Jun 18, 2021
29f0121
Merge pull request #2636 from NNboru/patch-1
iliakan Jun 18, 2021
de36d0d
update one code comment in 1-js/09-classes/04-private-protected-prope…
ZYinMD Jun 18, 2021
c45e78f
Maybe. "accessors" link
joaquinelio Jun 18, 2021
d43bdd2
slightly improve clarity on Promise.all()
ZYinMD Jun 19, 2021
e49bc3b
Merge pull request #2627 from ZYinMD/patch-5
iliakan Jun 19, 2021
e877796
closes #2641
iliakan Jun 19, 2021
ff53f06
minor fixes
iliakan Jun 19, 2021
cf82cc3
minor fixes
iliakan Jun 19, 2021
85282ef
minor fixes
iliakan Jun 19, 2021
a40ca9a
minor fixes
iliakan Jun 19, 2021
54347b7
minor fixes
iliakan Jun 19, 2021
df6e5a4
minor fixes
iliakan Jun 19, 2021
e769408
minor fixes
iliakan Jun 19, 2021
de81cb4
minor fixes
iliakan Jun 19, 2021
7dacfd4
minor fixes
iliakan Jun 19, 2021
3661393
minor fixes
iliakan Jun 19, 2021
1b16f9d
Merge pull request #2640 from ZYinMD/patch-17
iliakan Jun 19, 2021
6f14c39
Merge pull request #2639 from joaquinelio/patch-4
iliakan Jun 19, 2021
52eaa63
typo
joaquinelio Jun 20, 2021
9847492
Typo in Ch 15 Functions
Yoona8 Jun 20, 2021
140c75d
Merge pull request #2644 from Yoona8/master
iliakan Jun 20, 2021
ffe91a6
Merge pull request #2643 from joaquinelio/patch-6
iliakan Jun 20, 2021
8558fa8
Merge pull request #2638 from ZYinMD/patch-16
iliakan Jun 20, 2021
b19a6f0
minor fixes
iliakan Jun 21, 2021
66bad3f
fix typo in 5-network/02-formdata
ZYinMD Jun 22, 2021
d7c2f08
Add one letter in 5-network/03-fetch-progress
ZYinMD Jun 22, 2021
c4efc35
minor grammar change in webcomponents-intro
ZYinMD Jun 23, 2021
b855f6c
add a section about css animation performance
ZYinMD Jun 24, 2021
9b99012
Merge pull request #2654 from ZYinMD/patch-24
iliakan Jun 24, 2021
c41361f
animation
iliakan Jun 24, 2021
8b3730b
minor fixes
iliakan Jun 24, 2021
2961588
minor fixes
iliakan Jun 24, 2021
753182b
minor fixes
iliakan Jun 24, 2021
7d838b3
minor fixes
iliakan Jun 24, 2021
32f01fb
minor fixes
iliakan Jun 24, 2021
6c15ba4
minor fixes
iliakan Jun 24, 2021
771aab4
minor fixes
iliakan Jun 24, 2021
2eb4251
minor fixes
iliakan Jun 24, 2021
2811211
minor fixes
iliakan Jun 24, 2021
27af482
minor fixes
iliakan Jun 24, 2021
934d32b
minor fixes
iliakan Jun 24, 2021
4420427
minor fixes
iliakan Jun 24, 2021
e609815
minor fixes
iliakan Jun 24, 2021
e06bc63
minor fixes
iliakan Jun 24, 2021
e79ce9d
minor fixes
iliakan Jun 25, 2021
c001068
minor fixes
iliakan Jun 25, 2021
dab34f7
minor fixes
iliakan Jun 26, 2021
e9d2a31
minor fixes
iliakan Jun 26, 2021
a0af69e
minor fixes
iliakan Jun 26, 2021
4ed51aa
minor fixes
iliakan Jun 26, 2021
54688eb
minor fixes
iliakan Jun 26, 2021
6dda47f
minor fixes
iliakan Jun 26, 2021
e8d7f37
minor fixes
iliakan Jun 26, 2021
9bba570
minor fixes
iliakan Jun 26, 2021
7725acc
minor fixes
iliakan Jun 26, 2021
bed62e1
Add generator.return
Manik2375 Jun 27, 2021
624b48b
Update article.md
Manik2375 Jun 27, 2021
8db6519
minor fixes
iliakan Jun 27, 2021
8752573
minor fixes
iliakan Jun 27, 2021
76656bd
minor fixes
iliakan Jun 27, 2021
16b9bda
minor fixes
iliakan Jun 28, 2021
2275894
Merge pull request #2657 from Manik2375/generator.return
iliakan Jul 1, 2021
e195256
Response header name is changed to the right one
websavva Jul 3, 2021
16de27d
Fix a small grammar mistake
iliyu Jul 4, 2021
89e22f8
confusing line
joaquinelio Jul 13, 2021
02c75d2
Update task.md
joaquinelio Jul 13, 2021
19ec58b
Update article.md
Gammadon Jul 16, 2021
ce38273
add a missing colon
mahdyar Jul 17, 2021
c3214e7
Update article.md
iliakan Jul 21, 2021
1bf6973
Merge pull request #2673 from mahdyar/patch-1
iliakan Jul 22, 2021
667eb56
Merge pull request #2672 from Gammadon/patch-1
iliakan Jul 22, 2021
a5f339e
Merge pull request #2670 from joaquinelio/patch-6
iliakan Jul 22, 2021
237d883
Merge pull request #2662 from riri-yu/patch-1
iliakan Jul 22, 2021
cb97b72
Merge pull request #2661 from WebSavva/patch-1
iliakan Jul 22, 2021
df215cd
Merge pull request #2653 from ZYinMD/patch-21
iliakan Jul 22, 2021
614c85a
minor fixes
iliakan Jul 22, 2021
0082fbe
minor fixes
iliakan Jul 22, 2021
173ce27
Merge pull request #2649 from ZYinMD/patch-20
iliakan Jul 22, 2021
823eea4
Merge pull request #2648 from ZYinMD/patch-19
iliakan Jul 22, 2021
2957e71
minor fixes
iliakan Jul 23, 2021
1b1a2c4
minor fixes
iliakan Jul 23, 2021
9c5388c
pointer events improvements
iliakan Jul 24, 2021
57ff060
minor fixes
iliakan Jul 24, 2021
2a6fd54
old and new
joaquinelio Jul 26, 2021
ef8d576
Merge pull request #2680 from joaquinelio/patch-4
iliakan Jul 26, 2021
05a97a0
Update article.md
RainbowDashy Aug 1, 2021
12d7968
Make use of `loadJson` inside `loadGithubUser`
Aug 6, 2021
1808fe3
slider not working on movile
joaquinelio Aug 8, 2021
4a7fe13
Update index.html
joaquinelio Aug 8, 2021
58f9c8d
minor fixes
iliakan Aug 8, 2021
bc08fd1
Merge pull request #2689 from joaquinelio/patch-8
iliakan Aug 8, 2021
6b4cfc2
Fix grammar
siimpragi Aug 9, 2021
d404087
Fix typo.
odsantos Aug 9, 2021
95ad576
Update article.md
msmilkshake Aug 11, 2021
f17c07a
Fix compound interest formula
shvchk Aug 14, 2021
a19e517
Update URLs
odsantos Aug 14, 2021
d3ae613
Merge pull request #2683 from RainbowDashy/patch-1
iliakan Aug 14, 2021
ed3b2c0
Merge pull request #2696 from odsantos/property-descriptors
iliakan Aug 14, 2021
71688e7
Merge pull request #2695 from shvchk/master
iliakan Aug 14, 2021
7edd7c3
Merge pull request #2694 from msmilkshake/patch-1
iliakan Aug 14, 2021
71f8a9e
Merge pull request #2693 from odsantos/css-animations-typo
iliakan Aug 14, 2021
3b7a35e
Merge pull request #2692 from siimpragi/patch-1
iliakan Aug 14, 2021
a6c0fad
Merge pull request #2686 from mindv0rtex/patch-1
iliakan Aug 14, 2021
4d01fc2
minor fixes
iliakan Aug 15, 2021
1b31575
promise chain flow
joaquinelio Aug 15, 2021
8287e24
edge
joaquinelio Aug 16, 2021
623737b
Update article.md
deisner Aug 21, 2021
22b7b51
Update article.md
Aug 26, 2021
e69a943
Update urls
imba-tjd Aug 27, 2021
08a5308
Update article.md
baooab Sep 11, 2021
1059096
Update URL.
odsantos Sep 14, 2021
df39e1a
Update article.md
vladdoroniuk Sep 14, 2021
76ef126
Fix typo
rizkyzhang Sep 22, 2021
7abc297
picture minor fixes
iliakan Sep 25, 2021
b09e38c
minor fixes
iliakan Sep 25, 2021
7651ae0
minor typo
fionatagious Oct 1, 2021
2f98054
chore: fix a typo
mahdyar Oct 4, 2021
f4801c3
closes #2738
iliakan Oct 10, 2021
171d2e7
Merge pull request #2731 from mahdyar/patch-1
iliakan Oct 10, 2021
3d47402
Merge pull request #2729 from fionatagious/patch-1
iliakan Oct 10, 2021
5c1ee32
Merge pull request #2725 from rizkyzhang/patch-6
iliakan Oct 10, 2021
1c63023
Merge pull request #2721 from xirly/master
iliakan Oct 10, 2021
9e4a1e9
Merge pull request #2720 from odsantos/object-references
iliakan Oct 10, 2021
8794b71
Merge pull request #2717 from baooab/patch-9
iliakan Oct 10, 2021
2e494c7
Merge pull request #2697 from joaquinelio/patch-4
iliakan Oct 10, 2021
f1210b4
minor
iliakan Oct 10, 2021
cbc4350
Merge pull request #2698 from joaquinelio/patch-5
iliakan Oct 10, 2021
0d67376
Merge pull request #2701 from deisner/patch-1
iliakan Oct 10, 2021
ab2c57c
Merge pull request #2704 from wilburn98/master
iliakan Oct 10, 2021
193319c
Merge pull request #2705 from imba-tjd/patch-1
iliakan Oct 10, 2021
e3b10e6
sort-by-field fix
joneskj55 Oct 10, 2021
91a89ea
Update article.md
LexaWin Oct 11, 2021
eda333d
minor fixes
iliakan Oct 12, 2021
4397c7f
not a right comparison
Jiapan-Yu Oct 21, 2021
c20baa7
Add missing "!"
mahdiHash Oct 21, 2021
db074cd
Remove redundant word in Possible Mistakes section
vigu86 Oct 22, 2021
e0624c3
Update article.md
dneey Oct 22, 2021
1310d54
fix typo
KennethKinLum Oct 23, 2021
4c2658d
Fixed a grammatical error
zaibugemi Oct 24, 2021
6250c91
Merge pull request #1 from zaibugemi/zaibugemi-patch-1
zaibugemi Oct 24, 2021
3699f73
async-await on top
iliakan Oct 25, 2021
277fbd2
Merge pull request #2762 from zaibugemi/master
iliakan Oct 25, 2021
2a5c881
minor fixes
iliakan Oct 25, 2021
e95cab9
Merge pull request #2741 from joneskj55/patch-1
iliakan Oct 25, 2021
51be747
Merge pull request #2744 from LexaWin/patch-1
iliakan Oct 25, 2021
aed8070
Merge pull request #2750 from Jiapan-Yu/master
iliakan Oct 25, 2021
20da240
Merge pull request #2751 from mahdiHashemi14/master
iliakan Oct 25, 2021
3c62ecc
Merge pull request #2753 from vigu86/patch-1
iliakan Oct 25, 2021
676319d
Merge pull request #2755 from dneey/patch-2
iliakan Oct 25, 2021
3efe4cf
Merge pull request #2759 from KennethKinLum/patch-14
iliakan Oct 25, 2021
9dc5f3e
minor fixes
iliakan Oct 25, 2021
91e9b9c
minor fixes
iliakan Oct 25, 2021
6be354d
minor fixes
iliakan Oct 25, 2021
2ac7526
minor fixes
iliakan Oct 25, 2021
8308537
closes #2757
iliakan Oct 25, 2021
6989312
closes #2752
iliakan Oct 25, 2021
cc18823
minor fixes
iliakan Nov 1, 2021
be69f34
minor fixes
iliakan Nov 1, 2021
9fcffe1
minor fixes
iliakan Nov 1, 2021
15f7acf
minor fixes
iliakan Nov 1, 2021
4541b7a
minor fixes
iliakan Nov 3, 2021
a829155
minor fixes
iliakan Nov 12, 2021
c869499
merging all conflicts
iliakan Dec 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ sftp-config.json
Thumbs.db


/svgs
10 changes: 5 additions & 5 deletions 1-js/01-getting-started/1-intro/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ The browser has an embedded engine sometimes called a "JavaScript virtual machin

Different engines have different "codenames". For example:

- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome and Opera.
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome, Opera and Edge.
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- in Firefox.
- ...There are other codenames like "Chakra" for IE, "JavaScriptCore", "Nitro" and "SquirrelFish" for Safari, etc.

The terms above are good to remember because they are used in developer articles on the internet. We'll use them too. For instance, if "a feature X is supported by V8", then it probably works in Chrome and Opera.
The terms above are good to remember because they are used in developer articles on the internet. We'll use them too. For instance, if "a feature X is supported by V8", then it probably works in Chrome, Opera and Edge.

```smart header="How do engines work?"

Expand Down Expand Up @@ -59,7 +59,7 @@ For instance, in-browser JavaScript is able to:

## What CAN'T in-browser JavaScript do?

JavaScript's abilities in the browser are limited for the sake of the user's safety. The aim is to prevent an evil webpage from accessing private information or harming the user's data.
JavaScript's abilities in the browser are limited for the sake of a user's safety. The aim is to prevent an evil webpage from accessing private information or harming the user's data.

Examples of such restrictions include:

Expand All @@ -86,7 +86,7 @@ There are at least *three* great things about JavaScript:
```compare
+ Full integration with HTML/CSS.
+ Simple things are done simply.
+ Support by all major browsers and enabled by default.
+ Supported by all major browsers and enabled by default.
```
JavaScript is the only browser technology that combines these three things.

Expand Down Expand Up @@ -118,5 +118,5 @@ There are more. Of course, even if we use one of transpiled languages, we should
## Summary

- JavaScript was initially created as a browser-only language, but it is now used in many other environments as well.
- Today, JavaScript has a unique position as the most widely-adopted browser language with full integration in HTML/CSS.
- Today, JavaScript has a unique position as the most widely-adopted browser language, fully integrated with HTML/CSS.
- There are many languages that get "transpiled" to JavaScript and provide certain features. It is recommended to take a look at them, at least briefly, after mastering JavaScript.
1 change: 0 additions & 1 deletion 1-js/01-getting-started/3-code-editors/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ In practice, lightweight editors may have a lot of plugins including directory-l
The following options deserve your attention:

- [Atom](https://atom.io/) (cross-platform, free).
- [Visual Studio Code](https://code.visualstudio.com/) (cross-platform, free).
- [Sublime Text](http://www.sublimetext.com) (cross-platform, shareware).
- [Notepad++](https://notepad-plus-plus.org/) (Windows, free).
- [Vim](http://www.vim.org/) and [Emacs](https://www.gnu.org/software/emacs/) are also cool if you know how to use them.
Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/01-hello-world/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Script files are attached to HTML with the `src` attribute:
<script src="/path/to/script.js"></script>
```

Here, `/path/to/script.js` is an absolute path to the script from the site root. One can also provide a relative path from the current page. For instance, `src="script.js"` would mean a file `"script.js"` in the current folder.
Here, `/path/to/script.js` is an absolute path to the script from the site root. One can also provide a relative path from the current page. For instance, `src="script.js"`, just like `src="./script.js"`, would mean a file `"script.js"` in the current folder.

We can give a full URL as well. For instance:

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/04-variables/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Now, we can put some data into it by using the assignment operator `=`:
let message;

*!*
message = 'Hello'; // store the string
message = 'Hello'; // store the string 'Hello' in the variable named message
*/!*
```

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/09-comparison/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ In JavaScript they are written like this:
- Greater/less than: <code>a &gt; b</code>, <code>a &lt; b</code>.
- Greater/less than or equals: <code>a &gt;= b</code>, <code>a &lt;= b</code>.
- Equals: `a == b`, please note the double equality sign `==` means the equality test, while a single one `a = b` means an assignment.
- Not equals. In maths the notation is <code>&ne;</code>, but in JavaScript it's written as <code>a != b</code>.
- Not equals: In maths the notation is <code>&ne;</code>, but in JavaScript it's written as <code>a != b</code>.

In this article we'll learn more about different types of comparisons, how JavaScript makes them, including important peculiarities.

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/11-logical-operators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ This leads to some interesting usage compared to a "pure, classical, boolean-onl

It means that `||` processes its arguments until the first truthy value is reached, and then the value is returned immediately, without even touching the other argument.

That importance of this feature becomes obvious if an operand isn't just a value, but an expression with a side effect, such as a variable assignment or a function call.
The importance of this feature becomes obvious if an operand isn't just a value, but an expression with a side effect, such as a variable assignment or a function call.

In the example below, only the second message is printed:

Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/13-while-for/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Let's examine the `for` statement part-by-part:

| part | | |
|-------|----------|----------------------------------------------------------------------------|
| begin | `i = 0` | Executes once upon entering the loop. |
| begin | `let i = 0` | Executes once upon entering the loop. |
| condition | `i < 3`| Checked before every loop iteration. If false, the loop stops. |
| body | `alert(i)`| Runs again and again while the condition is truthy. |
| step| `i++` | Executes after the body on each iteration. |
Expand Down Expand Up @@ -377,7 +377,7 @@ label: {
}
```

...Although, 99.9% of the time `break` used is inside loops, as we've seen in the examples above.
...Although, 99.9% of the time `break` is used inside loops, as we've seen in the examples above.

A `continue` is only possible from inside a loop.
````
Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/15-function-basics/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ In other words, to put these terms straight:

We declare functions listing their parameters, then call them passing arguments.

In the example above, one might say: "the function `sayMessage` is declared with two parameters, then called with two arguments: `from` and `"Hello"`".
In the example above, one might say: "the function `showMessage` is declared with two parameters, then called with two arguments: `from` and `"Hello"`".


## Default values
Expand Down Expand Up @@ -247,7 +247,7 @@ function showMessage(text) {
showMessage(); // empty message
```

...Or we could use the `??` operator:
...Or we could use the `||` operator:

```js
function showMessage(text) {
Expand Down
10 changes: 5 additions & 5 deletions 1-js/03-code-quality/02-coding-style/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@ The great thing about them is that style-checking can also find some bugs, like

Here are some well-known linting tools:

- [JSLint](http://www.jslint.com/) -- one of the first linters.
- [JSHint](http://www.jshint.com/) -- more settings than JSLint.
- [ESLint](http://eslint.org/) -- probably the newest one.
- [JSLint](https://www.jslint.com/) -- one of the first linters.
- [JSHint](https://jshint.com/) -- more settings than JSLint.
- [ESLint](https://eslint.org/) -- probably the newest one.

All of them can do the job. The author uses [ESLint](http://eslint.org/).
All of them can do the job. The author uses [ESLint](https://eslint.org/).

Most linters are integrated with many popular editors: just enable the plugin in the editor and configure the style.

Expand Down Expand Up @@ -335,7 +335,7 @@ Here's an example of an `.eslintrc` file:

Here the directive `"extends"` denotes that the configuration is based on the "eslint:recommended" set of settings. After that, we specify our own.

It is also possible to download style rule sets from the web and extend them instead. See <http://eslint.org/docs/user-guide/getting-started> for more details about installation.
It is also possible to download style rule sets from the web and extend them instead. See <https://eslint.org/docs/user-guide/getting-started> for more details about installation.

Also certain IDEs have built-in linting, which is convenient but not as customizable as ESLint.

Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/06-polyfills/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Here, in this chapter, our purpose is to get the gist of how they work, and thei

## Transpilers

A [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler) is a special piece of software that can parse ("read and understand") modern code, and rewrite it using older syntax constructs, so that the result would be the same.
A [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler) is a special piece of software that translates source code to another source code. It can parse ("read and understand") modern code and rewrite it using older syntax constructs, so that it'll also work in outdated engines.

E.g. JavaScript before year 2020 didn't have the "nullish coalescing operator" `??`. So, if a visitor uses an outdated browser, it may fail to understand the code like `height = height ?? 100`.

Expand Down
2 changes: 1 addition & 1 deletion 1-js/04-object-basics/02-object-copy/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ clone.name = "Pete"; // changed the data in it
alert( user.name ); // still John in the original object
```

Also we can use the method [Object.assign](mdn:js/Object/assign) for that.
Also we can use the method [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) for that.

The syntax is:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ importance: 2

# Two functions – one object

Is it possible to create functions `A` and `B` such as `new A()==new B()`?
Is it possible to create functions `A` and `B` so that `new A() == new B()`?

```js no-beautify
function A() { ... }
Expand Down
6 changes: 3 additions & 3 deletions 1-js/04-object-basics/09-object-toprimitive/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ In case of such operations, objects are auto-converted to primitives, and then t

That's an important limitation, as the result of `obj1 + obj2` can't be another object!

E.g. we can't make objects representing vectors or matrices (or archievements or whatever), add them and expect a "summed" object as the result. Such architectural feats are automatically "off the board".
E.g. we can't make objects representing vectors or matrices (or achievements or whatever), add them and expect a "summed" object as the result. Such architectural feats are automatically "off the board".

So, because we can't do much here, there's no maths with objects in real projects. When it happens, it's usually because of a coding mistake.

Expand Down Expand Up @@ -133,7 +133,7 @@ As we can see from the code, `user` becomes a self-descriptive string or a money

If there's no `Symbol.toPrimitive` then JavaScript tries to find methods `toString` and `valueOf`:

- For the "string" hint: `toString`, and if it doesn't exist, then `valueOf` (so `toString` has the priority for stirng conversions).
- For the "string" hint: `toString`, and if it doesn't exist, then `valueOf` (so `toString` has the priority for string conversions).
- For other hints: `valueOf`, and if it doesn't exist, then `toString` (so `valueOf` has the priority for maths).

Methods `toString` and `valueOf` come from ancient times. They are not symbols (symbols did not exist that long ago), but rather "regular" string-named methods. They provide an alternative "old-style" way to implement the conversion.
Expand Down Expand Up @@ -274,4 +274,4 @@ The conversion algorithm is:

In practice, it's often enough to implement only `obj.toString()` as a "catch-all" method for string conversions that should return a "human-readable" representation of an object, for logging or debugging purposes.

As for math operations, JavaScript doesn't provide a way to "override" them using methods, so real life projects rarely use them on objects.
As for math operations, JavaScript doesn't provide a way to "override" them using methods, so real life projects rarely use them on objects.
2 changes: 1 addition & 1 deletion 1-js/05-data-types/01-primitives-methods/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The solution looks a little bit awkward, but here it is:
2. The language allows access to methods and properties of strings, numbers, booleans and symbols.
3. In order for that to work, a special "object wrapper" that provides the extra functionality is created, and then is destroyed.

The "object wrappers" are different for each primitive type and are called: `String`, `Number`, `Boolean` and `Symbol`. Thus, they provide different sets of methods.
The "object wrappers" are different for each primitive type and are called: `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. Thus, they provide different sets of methods.

For instance, there exists a string method [str.toUpperCase()](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase) that returns a capitalized `str`.

Expand Down
15 changes: 8 additions & 7 deletions 1-js/05-data-types/02-number/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ In modern JavaScript, there are two types of numbers:

1. Regular numbers in JavaScript are stored in 64-bit format [IEEE-754](https://en.wikipedia.org/wiki/IEEE_754-2008_revision), also known as "double precision floating point numbers". These are numbers that we're using most of the time, and we'll talk about them in this chapter.

2. BigInt numbers, to represent integers of arbitrary length. They are sometimes needed, because a regular number can't exceed <code>2<sup>53</sup></code> or be less than <code>-2<sup>53</sup></code>. As bigints are used in few special areas, we devote them a special chapter <info:bigint>.
2. BigInt numbers, to represent integers of arbitrary length. They are sometimes needed, because a regular number can't safely exceed <code>2<sup>53</sup></code> or be less than <code>-2<sup>53</sup></code>. As bigints are used in few special areas, we devote them a special chapter <info:bigint>.

So here we'll talk about regular numbers. Let's expand our knowledge of them.

Expand Down Expand Up @@ -37,8 +37,8 @@ alert( 7.3e9 ); // 7.3 billions (same as 7300000000 or 7_300_000_000)
In other words, `e` multiplies the number by `1` with the given zeroes count.

```js
1e3 = 1 * 1000 // e3 means *1000
1.23e6 = 1.23 * 1000000 // e6 means *1000000
1e3 === 1 * 1000; // e3 means *1000
1.23e6 === 1.23 * 1000000; // e6 means *1000000
```

Now let's write something very small. Say, 1 microsecond (one millionth of a second):
Expand All @@ -53,16 +53,16 @@ Just like before, using `"e"` can help. If we'd like to avoid writing the zeroes
let ms = 1e-6; // six zeroes to the left from 1
```

If we count the zeroes in `0.000001`, there are 6 of them. So naturally it's `1e-6`.
If we count the zeroes in `0.000001`, there are 6 of them. So naturally it's `1e-6`.

In other words, a negative number after `"e"` means a division by 1 with the given number of zeroes:

```js
// -3 divides by 1 with 3 zeroes
1e-3 = 1 / 1000 (=0.001)
1e-3 === 1 / 1000; // 0.001

// -6 divides by 1 with 6 zeroes
1.23e-6 = 1.23 / 1000000 (=0.00000123)
1.23e-6 === 1.23 / 1000000; // 0.00000123
```

### Hex, binary and octal numbers
Expand Down Expand Up @@ -118,6 +118,7 @@ Please note that two dots in `123456..toString(36)` is not a typo. If we want to
If we placed a single dot: `123456.toString(36)`, then there would be an error, because JavaScript syntax implies the decimal part after the first dot. And if we place one more dot, then JavaScript knows that the decimal part is empty and now goes the method.

Also could write `(123456).toString(36)`.

```

## Rounding
Expand Down Expand Up @@ -328,7 +329,7 @@ let num = +prompt("Enter a number", '');
alert( isFinite(num) );
```

Please note that an empty or a space-only string is treated as `0` in all numeric functions including `isFinite`.
Please note that an empty or a space-only string is treated as `0` in all numeric functions including `isFinite`.

```smart header="Compare with `Object.is`"

Expand Down
2 changes: 1 addition & 1 deletion 1-js/05-data-types/03-string/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Here's the full list:
| Character | Description |
|-----------|-------------|
|`\n`|New line|
|`\r`|Carriage return: not used alone. Windows text files use a combination of two characters `\r\n` to represent a line break. |
|`\r`|In Windows text files a combination of two characters `\r\n` represents a new break, while on non-Windows OS it's just `\n`. That's for historical reasons, most Windows software also understands `\n`. |
|`\'`, `\"`|Quotes|
|`\\`|Backslash|
|`\t`|Tab|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ importance: 4

# Create keyed object from array

Let's say we received an array of users in the form `{id:..., name:..., age... }`.
Let's say we received an array of users in the form `{id:..., name:..., age:... }`.

Create a function `groupById(arr)` that creates an object from it, with `id` as the key, and array items as values.

Expand Down
11 changes: 6 additions & 5 deletions 1-js/05-data-types/09-keys-values-entries/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Objects lack many methods that exist for arrays, e.g. `map`, `filter` and others
If we'd like to apply them, then we can use `Object.entries` followed by `Object.fromEntries`:

1. Use `Object.entries(obj)` to get an array of key/value pairs from `obj`.
2. Use array methods on that array, e.g. `map`.
2. Use array methods on that array, e.g. `map`, to transform these key/value pairs.
3. Use `Object.fromEntries(array)` on the resulting array to turn it back into an object.

For example, we have an object with prices, and would like to double them:
Expand All @@ -91,12 +91,13 @@ let prices = {

*!*
let doublePrices = Object.fromEntries(
// convert to array, map, and then fromEntries gives back the object
Object.entries(prices).map(([key, value]) => [key, value * 2])
// convert prices to array, map each key/value pair into another pair
// and then fromEntries gives back the object
Object.entries(prices).map(entry => [entry[0], entry[1] * 2])
);
*/!*

alert(doublePrices.meat); // 8
```
```

It may look difficult at first sight, but becomes easy to understand after you use it once or twice. We can make powerful chains of transforms this way.
It may look difficult at first sight, but becomes easy to understand after you use it once or twice. We can make powerful chains of transforms this way.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ printReverseList(list);

# Using a loop

The loop variant is also a little bit more complicated then the direct output.
The loop variant is also a little bit more complicated than the direct output.

There is no way to get the last value in our `list`. We also can't "go back".

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("byField", function(){
{ name: "John", age: 20, surname: "Johnson"},
];
let ageSortedAnswer = users.sort(byField("age"));
assert.deepEqual(ageSortedKey, ageSortedKey);
assert.deepEqual(ageSortedKey, ageSortedAnswer);
});

it("sorts users by surname", function(){
Expand Down
2 changes: 1 addition & 1 deletion 1-js/06-advanced-functions/04-var/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
```smart header="This article is for understanding old scripts"
The information in this article is useful for understanding old scripts.

That's not how we write a new code.
That's not how we write new code.
```

In the very first chapter about [variables](info:variables), we mentioned three ways of variable declaration:
Expand Down
4 changes: 2 additions & 2 deletions 1-js/06-advanced-functions/10-bind/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ let user = {

let say = user.say.bind(user);

say("Hello"); // Hello, John ("Hello" argument is passed to say)
say("Bye"); // Bye, John ("Bye" is passed to say)
say("Hello"); // Hello, John! ("Hello" argument is passed to say)
say("Bye"); // Bye, John! ("Bye" is passed to say)
```

````smart header="Convenience method: `bindAll`"
Expand Down
Loading