Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
735 commits
Select commit Hold shift + click to select a range
99b2a09
Merge pull request #2437 from lumosmind/patch-68
iliakan Jan 13, 2021
8eb6f97
minor fixes
iliakan Jan 13, 2021
f797858
closes #2398
iliakan Jan 14, 2021
bda37e2
Update article.md
Zearin Jan 15, 2021
3a0b3f4
Merge pull request #2430 from joaquinelio/patch-1
iliakan Jan 16, 2021
9e1d531
Fix mismatched alert text
emek Jan 16, 2021
18417c3
Update article.md
Zearin Jan 16, 2021
8806d5b
Update article.md
Zearin Jan 16, 2021
37c906c
fix typo
msisaifu Jan 17, 2021
0f65c39
the type name is lookbehind instead of lookahead
msisaifu Jan 17, 2021
bdb19f6
too wordy explanation
joaquinelio Jan 17, 2021
04e2514
Update article.md
redrambles Jan 20, 2021
0deca2c
typo
martynov-94 Jan 21, 2021
6451000
Spelling error & wrong idiom
bierlingm Jan 21, 2021
ab7b646
Merge pull request #2453 from bierlingm/patch-1
iliakan Jan 21, 2021
acf62b0
minor fixes
iliakan Jan 21, 2021
6e326fb
Merge pull request #2449 from redrambles/patch-2
iliakan Jan 21, 2021
29827e8
Merge pull request #2447 from joaquinelio/patch-1
iliakan Jan 21, 2021
0c4913c
minor fixes
iliakan Jan 21, 2021
354c633
Merge pull request #2445 from msisaifu/fix-typo
iliakan Jan 21, 2021
b462bdd
Merge pull request #2443 from emek/minor-text-fix
iliakan Jan 21, 2021
21a751a
to both -> both to
martynov-94 Jan 22, 2021
f0d389e
Merge pull request #2457 from martynov-94/patch-3
iliakan Jan 22, 2021
7bd55a4
Merge pull request #2458 from martynov-94/patch-2
iliakan Jan 22, 2021
13a6a75
modify alternative method in comment of mixins' code example
AmosChenYQ Jan 23, 2021
97ef862
Merge pull request #2462 from AmosChenYQ/amoschen-classes-correct
iliakan Jan 23, 2021
aef2a02
Update task.md
lijunkang12 Jan 23, 2021
93b1051
unify content with cosmetic changes
Jan 25, 2021
ad01279
restore try-catch-flow.svg
Jan 25, 2021
6975a01
fix undefined to pass test
aliaghdam Jan 25, 2021
b93be73
Update article.md
Zearin Jan 25, 2021
d78ce9c
Update article.md
Zearin Jan 25, 2021
4711ee4
Update article.md
Zearin Jan 25, 2021
936bea2
fix word
eucalyptus-viminalis Jan 27, 2021
1246f79
Fix article typo
helloimjordan Jan 28, 2021
3f8ab24
Fix typo in "liseners" on line 21
pawel-cebula Jan 29, 2021
526b216
fix typo: missing semicolon after let ladder = { }
seamissu Jan 29, 2021
82e4e21
there are four logical operators in JS
lumosmind Feb 1, 2021
21d444f
Add will to modyfying document task 1 sentence
f6p Feb 1, 2021
4df24f3
Add missing semicolon in Arrow Functions (1-6-12)
MuhammedZakir Feb 1, 2021
18534d3
Clearer CachingDecorator comments
notapatch Feb 1, 2021
96e95bb
Update article.md
asamant Feb 1, 2021
005204e
conflict with "rest syntax"
lumosmind Feb 2, 2021
e825d25
Merge pull request #2487 from lumosmind/patch-4
iliakan Feb 2, 2021
a5523ad
Merge pull request #2486 from asamant/asamant-patch-1
iliakan Feb 2, 2021
ebd0d11
Merge pull request #2485 from notapatch/pr-call-apply-decorators-clea…
iliakan Feb 2, 2021
f3dc5d1
Merge pull request #2484 from MuhammedZakir/patch-1
iliakan Feb 2, 2021
23674dd
Merge pull request #2483 from f6p/create-vs-inner-grammar
iliakan Feb 2, 2021
0c8a4fe
Merge pull request #2482 from lumosmind/patch-3
iliakan Feb 2, 2021
0806399
minor fixes
iliakan Feb 2, 2021
355c2e3
Merge pull request #2466 from aliaghdam/master
iliakan Feb 2, 2021
5a9f6c4
Merge pull request #2476 from seamissu/patch-3
iliakan Feb 2, 2021
0f00709
Merge pull request #2475 from pawel-123/patch-1
iliakan Feb 2, 2021
19bf2d3
Merge pull request #2469 from fibretothepremises/patch-1
iliakan Feb 2, 2021
3fa4c32
minor fixes
iliakan Feb 2, 2021
1c24978
Merge pull request #2470 from helloimjordan/patch-1
iliakan Feb 2, 2021
58c9aae
Merge pull request #2463 from lijunkang12/patch-1
iliakan Feb 2, 2021
7be7b28
Considering Promise.any there are 6 static methods
mikitachyzhyk Feb 2, 2021
7533c71
minor fixes
iliakan Feb 2, 2021
f014534
Remove comma after `e.g.` based on feedback
Zearin Feb 2, 2021
0d52720
needed 4 translated repos
joaquinelio Feb 4, 2021
c8a52a1
Add comments to article.md
knoxj1 Feb 4, 2021
ff9e2e2
Merge pull request #1 from knoxj1/knoxj1-patch-1
knoxj1 Feb 4, 2021
dd9833c
Update 2-ui/4-forms-controls/1-form-elements/article.md
knoxj1 Feb 10, 2021
879554f
Update article.md - fix syntax
eucalyptus-viminalis Feb 24, 2021
f6ae0b5
minor fixes
iliakan Feb 28, 2021
f452810
typo
joaquinelio Mar 2, 2021
fdcf507
Fix little formatting typo in 1.2.13 (loops)
T1mL3arn Mar 5, 2021
d9d1023
spread operator vs spread syntax
lumosmind Mar 8, 2021
e6bf25f
Merge pull request #2495 from joaquinelio/info
iliakan Mar 12, 2021
20fd4f8
Merge pull request #2496 from knoxj1/master
iliakan Mar 12, 2021
f267fad
Merge pull request #2504 from fibretothepremises/patch-2
iliakan Mar 12, 2021
7ec4f28
Merge pull request #2507 from joaquinelio/patch-1
iliakan Mar 12, 2021
e0f41ea
Merge pull request #2509 from T1mL3arn/patch-1
iliakan Mar 12, 2021
bf66ad6
Merge pull request #2511 from lumosmind/patch-6
iliakan Mar 12, 2021
a89de35
closes #2498
iliakan Mar 13, 2021
91aed38
minor fixes
iliakan Mar 13, 2021
78f7678
closes #2494
iliakan Mar 13, 2021
e4c769d
Merge pull request #2489 from mikitachyzhyk/patch-1
iliakan Mar 13, 2021
c3a9bbd
minor fixes
iliakan Mar 13, 2021
175574e
Merge pull request #2440 from Zearin/patch-1
iliakan Mar 13, 2021
8bc505a
closes #2459
iliakan Mar 13, 2021
7ad529e
Merge pull request #2464 from VibingCreator/master
iliakan Mar 13, 2021
bbf60dd
minor fixes
iliakan Mar 13, 2021
e01998b
minor fixes
iliakan Mar 14, 2021
b96642d
Add semicolon
shreenanda-8 Mar 15, 2021
51b2bec
Add semicolon
shreenanda-8 Mar 15, 2021
ff99720
CANCEL meaning
joaquinelio Mar 17, 2021
d4b3c13
Merge pull request #2526 from joaquinelio/patch-4
iliakan Mar 17, 2021
cf6be94
fix typo
seamissu Mar 17, 2021
065e31d
improve readability of article in chapter 8, async
hamirmahal Mar 16, 2021
74935be
link to deprecated v0
joaquinelio Mar 19, 2021
027b831
No polyfill needed any longer
joaquinelio Mar 19, 2021
cd4de4b
typo
joaquinelio Mar 23, 2021
081d7b2
typo
joaquinelio Mar 23, 2021
d464ee9
typo
joaquinelio Mar 23, 2021
a010fbc
typo
joaquinelio Mar 23, 2021
3855301
2 typos
LLyaudet Mar 24, 2021
8bc74f1
1 typo in 06-function-object
LLyaudet Mar 24, 2021
c2cbc4c
avoid race condition in 06-advanced-functions/09-call-apply-decorator…
LLyaudet Mar 24, 2021
33f8b4c
selection improvements
iliakan Mar 25, 2021
3264c4b
typo
joaquinelio Mar 25, 2021
f5583eb
Merge pull request #2520 from shreenanda-8/master
iliakan Mar 26, 2021
797c658
Merge pull request #2548 from joaquinelio/patch-10
iliakan Mar 26, 2021
532b64f
closes #2547
iliakan Mar 26, 2021
3b3f7c7
Merge pull request #2545 from LLyaudet/patch-6
iliakan Mar 26, 2021
0dc1961
Merge pull request #2542 from LLyaudet/patch-4
iliakan Mar 26, 2021
5f875ab
Merge pull request #2541 from LLyaudet/patch-3
iliakan Mar 26, 2021
677fb62
Merge pull request #2540 from joaquinelio/patch-9
iliakan Mar 26, 2021
ebfef9f
Merge pull request #2539 from joaquinelio/patch-8
iliakan Mar 26, 2021
0ec6e0c
Merge pull request #2538 from joaquinelio/patch-7
iliakan Mar 26, 2021
211e130
Merge pull request #2537 from joaquinelio/patch-6
iliakan Mar 26, 2021
d3f5a59
closes #2536
iliakan Mar 26, 2021
4dcd950
Merge pull request #2533 from joaquinelio/patch-5
iliakan Mar 26, 2021
8e0d226
Merge pull request #2532 from joaquinelio/patch-4
iliakan Mar 26, 2021
b8346a5
Merge pull request #2530 from hamirmahal/infra/update-article-in-asyn…
iliakan Mar 26, 2021
d4feed3
Merge pull request #2527 from seamissu/patch-5
iliakan Mar 26, 2021
b2bff50
closes #2525
iliakan Mar 26, 2021
7b76185
closes #2524
iliakan Mar 26, 2021
a4ba2bb
close #2534 by slightly changing 7-microtask-queue
hamirmahal Mar 26, 2021
a662e1c
typo
joaquinelio Mar 27, 2021
67230aa
code
joaquinelio Mar 28, 2021
32eb2f9
typo
joaquinelio Mar 28, 2021
4820b97
repeated word
joaquinelio Mar 28, 2021
01ebc30
typo
joaquinelio Mar 28, 2021
c06e21f
Few grammatical corrections
VenkataPavan2494 Mar 31, 2021
6d0b314
Fix grammatical error
tamiolaf Apr 1, 2021
c722cda
Update article.md
PhilipKirner Apr 1, 2021
334d4de
pseudo function expression
lumosmind Apr 4, 2021
023ec22
typos
joaquinelio Apr 5, 2021
b896887
Fix comma splice.
m4ttsch Apr 5, 2021
a2c36c9
Fix plural typo line 414
dylan-workhub Apr 9, 2021
6de9d70
typo
joaquinelio Apr 11, 2021
dbae68c
Plunker reminder #1775
joaquinelio Apr 11, 2021
8b7bf10
store vs keeps stored
joaquinelio Apr 12, 2021
9e52cf3
Merge pull request #2578 from joaquinelio/patch-15
iliakan Apr 12, 2021
d8be8b0
Add scrollX/scrollY
iliakan Apr 15, 2021
2b33873
Merge pull request #2577 from joaquinelio/patch-14
iliakan Apr 17, 2021
3d8ab89
Merge pull request #2575 from joaquinelio/patch-13
iliakan Apr 17, 2021
35d1c85
Merge pull request #2573 from dylan-workhub/patch-1
iliakan Apr 17, 2021
adb962b
closes #2572
iliakan Apr 17, 2021
09c3914
Merge pull request #2568 from m4ttsch/patch-1
iliakan Apr 17, 2021
362e9a9
Merge pull request #2566 from joaquinelio/patch-11
iliakan Apr 17, 2021
4742c7b
Merge pull request #2565 from lumosmind/patch-8
iliakan Apr 17, 2021
8c5d3bf
Merge pull request #2562 from PhilipKirner/patch-1
iliakan Apr 17, 2021
4092b7f
Merge pull request #2561 from tamiolaf/patch-1
iliakan Apr 17, 2021
8be1642
Merge pull request #2559 from VenkataPavan2494/patch-1
iliakan Apr 17, 2021
ba0b184
Merge pull request #2558 from joaquinelio/patch-9
iliakan Apr 17, 2021
a18c710
Merge pull request #2557 from joaquinelio/patch-8
iliakan Apr 17, 2021
1b4b347
Merge pull request #2556 from joaquinelio/patch-7
iliakan Apr 17, 2021
4b10919
Merge pull request #2550 from hamirmahal/feat/update-readability-of-7…
iliakan Apr 17, 2021
e8a1cd8
Merge pull request #2552 from joaquinelio/patch-4
iliakan Apr 17, 2021
870a88c
Merge pull request #2554 from joaquinelio/patch-5
iliakan Apr 17, 2021
7d624ef
typo it's
joaquinelio Apr 18, 2021
ffd8e03
typos? easier reading - review pls
joaquinelio Apr 18, 2021
6ab384f
Merge pull request #2584 from joaquinelio/patch-7
iliakan Apr 18, 2021
47b1ca8
Fix grammar and wrong information
Violet-Bora-Lee Apr 21, 2021
0ad314c
fix grammar
Violet-Bora-Lee Apr 22, 2021
62bc619
insert empty line
Violet-Bora-Lee Apr 22, 2021
8292f9c
Update article.md
JackStaples Apr 24, 2021
07b364d
Replace preposition with verb
mikemitchell574 Apr 29, 2021
981e34b
Update article.md
joecervino Apr 30, 2021
252cccf
always strict
joaquinelio May 7, 2021
5f972c8
fix(classes): replace [[FunctionKind]] with [[IsClassConstructor]]
H2rmone May 11, 2021
243a0b1
Merge pull request #2582 from joaquinelio/patch-4
iliakan May 13, 2021
055cab1
Merge pull request #2585 from Violet-Bora-Lee/patch-1
iliakan May 13, 2021
c78b2c9
Merge pull request #2586 from Violet-Bora-Lee/patch-2
iliakan May 13, 2021
10c3bcf
Merge pull request #2588 from Violet-Bora-Lee/patch-3
iliakan May 13, 2021
4f06415
closes #2583
iliakan May 13, 2021
74d14af
minor fixes
iliakan May 13, 2021
57e7d67
Merge pull request #2592 from JackStaples/patch-2
iliakan May 13, 2021
5e9db70
Merge pull request #2593 from mikemitchell574/master
iliakan May 13, 2021
0cbf55d
Merge pull request #2595 from josecervino/patch-1
iliakan May 13, 2021
094b829
Merge pull request #2598 from joaquinelio/patch-7
iliakan May 13, 2021
339535d
Merge pull request #2599 from H2rmone/master
iliakan May 13, 2021
3bf8830
Update article.md
iliakan May 13, 2021
237920b
Update article.md
iliakan May 13, 2021
33f1b11
minor fixes
iliakan May 13, 2021
6ad8930
minor fixes
iliakan May 13, 2021
fafab82
typo
joaquinelio May 15, 2021
4177be3
Merge pull request #2602 from joaquinelio/patch-4
iliakan May 16, 2021
80956ed
closes #2600
iliakan May 16, 2021
11e0890
Fix typo.
odsantos May 16, 2021
89183a0
minor fixes
iliakan May 16, 2021
bad5236
minor fixes
iliakan May 16, 2021
70049c3
minor fixes
iliakan May 16, 2021
859fa9b
minor fixes
iliakan May 16, 2021
fb09afc
minor fixes
iliakan May 16, 2021
f598b72
minor fixes
iliakan May 16, 2021
f841402
minor fixes
iliakan May 16, 2021
18a0394
minor fixes
iliakan May 16, 2021
ac96ede
Remove mentions of :host-context
web-padawan May 17, 2021
ae8248b
minor fixes
iliakan May 17, 2021
d2ae45d
Update article.md
Dorin-David May 20, 2021
ffa79a8
minor fixes
iliakan May 24, 2021
a917f9c
minor fixes
iliakan May 24, 2021
94837c2
minor fixes
iliakan May 24, 2021
3e74537
minor fixes
iliakan May 24, 2021
006343a
minor fixes
iliakan May 24, 2021
df45aed
minor fixes
iliakan May 24, 2021
8871521
minor fixes
iliakan May 24, 2021
1770074
minor fixes
iliakan May 24, 2021
3dbe9d1
minor fixes
iliakan May 24, 2021
2fc7cb2
minor fixes
iliakan May 24, 2021
649a159
minor fixes
iliakan May 24, 2021
62db4bb
minor fixes
iliakan May 24, 2021
3288801
minor fixes
iliakan May 24, 2021
6db4961
minor fixes
iliakan May 24, 2021
4343545
minor fixes
iliakan May 24, 2021
053cc05
minor fixes
iliakan May 24, 2021
842f0e2
minor fixes
iliakan May 24, 2021
70bb265
minor fixes
iliakan May 24, 2021
fc3c071
minor fixes
iliakan May 24, 2021
7a30a00
minor fixes
iliakan May 24, 2021
6cfa8b4
minor fixes
iliakan May 24, 2021
649c758
minor fixes
iliakan May 24, 2021
f2636ee
minor fixes
iliakan May 24, 2021
9ba208f
minor fixes
iliakan May 24, 2021
cf33b67
minor fixes
iliakan May 24, 2021
f8313dc
Update article.md
AhmedElaguab May 28, 2021
88ba2c2
Merge pull request #2 from AhmedElaguab/AhmedElaguab-fix-typo
AhmedElaguab May 28, 2021
4c35f59
"not required" vs "incorrect"
joaquinelio May 29, 2021
c2d5f8e
easier to read
joaquinelio Jun 4, 2021
52cb884
Update article.md
leviding Jun 7, 2021
6a742c4
Update article.md
leviding Jun 8, 2021
581802d
minor fixes
iliakan Jun 9, 2021
68172cc
typo
joaquinelio Jun 10, 2021
0e49461
typpo
joaquinelio Jun 10, 2021
964ba15
function parameters vs arguments
iliakan Jun 13, 2021
1ccd673
Merge pull request #2624 from joaquinelio/patch-11
iliakan Jun 13, 2021
54ff266
Merge pull request #2623 from joaquinelio/patch-9
iliakan Jun 13, 2021
2b1600e
Merge pull request #2622 from leviding/patch-37
iliakan Jun 13, 2021
581117f
Merge pull request #2621 from leviding/patch-36
iliakan Jun 13, 2021
dcf4b5b
closes #2619
iliakan Jun 13, 2021
2290bd6
Merge pull request #2616 from joaquinelio/patch-8
iliakan Jun 13, 2021
bcb47b7
Merge pull request #2612 from joaquinelio/patch-4
iliakan Jun 13, 2021
5f927bd
Merge pull request #2611 from AhmedElaguab/master
iliakan Jun 13, 2021
4d46f12
Merge pull request #2606 from Dorin-David/patch-1
iliakan Jun 13, 2021
e4ac603
Merge pull request #2605 from web-padawan/patch-1
iliakan Jun 13, 2021
ee5853d
Merge pull request #2604 from odsantos/regex-methods
iliakan Jun 13, 2021
bcf2e48
minor fixes
iliakan Jun 13, 2021
225a36f
Merge branch 'master' of github.com:javascript-tutorial/en.javascript…
iliakan Jun 13, 2021
617dfc7
minor fixes
iliakan Jun 13, 2021
e2d1823
minor fixes
iliakan Jun 13, 2021
614e29e
minor fixes
iliakan Jun 13, 2021
a171b0a
fix typo in 1-js/05-data-types/03-string
ZYinMD Jun 13, 2021
e527c61
Merge pull request #2630 from ZYinMD/patch-10
iliakan Jun 13, 2021
b258e8f
minor fixes
iliakan Jun 14, 2021
fb4fc33
minor fixes
iliakan Jun 15, 2021
d4d4180
merging all conflicts
iliakan Jun 15, 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
11 changes: 6 additions & 5 deletions 1-js/01-getting-started/1-intro/article.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# An Introduction to JavaScript

Let's see what's so special about JavaScript, what we can achieve with it, and which other technologies play well with it.
Let's see what's so special about JavaScript, what we can achieve with it, and what other technologies play well with it.

## What is JavaScript?

Expand All @@ -26,7 +26,7 @@ Different engines have different "codenames". For example:

- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome and Opera.
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- in Firefox.
- ...There are other codenames like "Chakra" for IE, "ChakraCore" for Microsoft Edge, "Nitro" and "SquirrelFish" for Safari, etc.
- ...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.

Expand Down Expand Up @@ -110,12 +110,13 @@ Examples of such languages:
- [TypeScript](http://www.typescriptlang.org/) is concentrated on adding "strict data typing" to simplify the development and support of complex systems. It is developed by Microsoft.
- [Flow](http://flow.org/) also adds data typing, but in a different way. Developed by Facebook.
- [Dart](https://www.dartlang.org/) is a standalone language that has its own engine that runs in non-browser environments (like mobile apps), but also can be transpiled to JavaScript. Developed by Google.
- [Brython](https://brython.info/) is a Python transpiler to JavaScript that allow to write application in pure Python without JavaScript.
- [Brython](https://brython.info/) is a Python transpiler to JavaScript that enables the writing of applications in pure Python without JavaScript.
- [Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) is a modern, concise and safe programming language that can target the browser or Node.

There are more. Of course, even if we use one of transpiled languages, we should also know JavaScript to really understand what we're doing.

## Summary

- JavaScript was initially created as a browser-only language, but 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 with HTML/CSS.
- 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.
- 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.
11 changes: 3 additions & 8 deletions 1-js/01-getting-started/2-manuals-specifications/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@ A new specification version is released every year. In-between these releases, t

To read about new bleeding-edge features, including those that are "almost standard" (so-called "stage 3"), see proposals at <https://github.com/tc39/proposals>.

Also, if you're in developing for the browser, then there are other specs covered in the [second part](info:browser-environment) of the tutorial.
Also, if you're developing for the browser, then there are other specifications covered in the [second part](info:browser-environment) of the tutorial.

## Manuals

- **MDN (Mozilla) JavaScript Reference** is a manual with examples and other information. It's great to get in-depth information about individual language functions, methods etc.
- **MDN (Mozilla) JavaScript Reference** is the main manual with examples and other information. It's great to get in-depth information about individual language functions, methods etc.

One can find it at <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.

Although, it's often best to use an internet search instead. Just use "MDN [term]" in the query, e.g. <https://google.com/search?q=MDN+parseInt> to search for `parseInt` function.


- **MSDN** – Microsoft manual with a lot of information, including JavaScript (often referred to as JScript). If one needs something specific to Internet Explorer, better go there: <http://msdn.microsoft.com/>.

Also, we can use an internet search with phrases such as "RegExp MSDN" or "RegExp MSDN jscript".
Although, it's often best to use an internet search instead. Just use "MDN [term]" in the query, e.g. <https://google.com/search?q=MDN+parseInt> to search for `parseInt` function.

## Compatibility tables

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 @@ -9,7 +9,7 @@ So first, let's see how we attach a script to a webpage. For server-side environ

## The "script" tag

JavaScript programs can be inserted into any part of an HTML document with the help of the `<script>` tag.
JavaScript programs can be inserted almost anywhere into an HTML document using the `<script>` tag.

For instance:

Expand Down
36 changes: 16 additions & 20 deletions 1-js/02-first-steps/02-structure/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ alert(3 +
+ 2);
```

The code outputs `6` because JavaScript does not insert semicolons here. It is intuitively obvious that if the line ends with a plus `"+"`, then it is an "incomplete expression", so the semicolon is not required. And in this case that works as intended.
The code outputs `6` because JavaScript does not insert semicolons here. It is intuitively obvious that if the line ends with a plus `"+"`, then it is an "incomplete expression", so a semicolon there would be incorrect. And in this case, that works as intended.

**But there are situations where JavaScript "fails" to assume a semicolon where it is really needed.**

Expand All @@ -56,40 +56,36 @@ Errors which occur in such cases are quite hard to find and fix.
If you're curious to see a concrete example of such an error, check this code out:

```js run
[1, 2].forEach(alert)
alert("Hello");

[1, 2].forEach(alert);
```

No need to think about the meaning of the brackets `[]` and `forEach` yet. We'll study them later. For now, just remember the result of the code: it shows `1` then `2`.
No need to think about the meaning of the brackets `[]` and `forEach` yet. We'll study them later. For now, just remember the result of running the code: it shows `Hello`, then `1`, then `2`.

Now, let's add an `alert` before the code and *not* finish it with a semicolon:
Now let's remove the semicolon after the `alert`:

```js run no-beautify
alert("There will be an error")
alert("Hello")

[1, 2].forEach(alert)
[1, 2].forEach(alert);
```

Now if we run the code, only the first `alert` is shown and then we have an error!

But everything is fine again if we add a semicolon after `alert`:
```js run
alert("All fine now");
The difference compared to the code above is only one character: the semicolon at the end of the first line is gone.

[1, 2].forEach(alert)
```
If we run this code, only the first `Hello` shows (and there's an error, you may need to open the console to see it). There are no numbers any more.

Now we have the "All fine now" message followed by `1` and `2`.
That's because JavaScript does not assume a semicolon before square brackets `[...]`. So, the code in the last example is treated as a single statement.


The error in the no-semicolon variant occurs because JavaScript does not assume a semicolon before square brackets `[...]`.

So, because the semicolon is not auto-inserted, the code in the first example is treated as a single statement. Here's how the engine sees it:
Here's how the engine sees it:

```js run no-beautify
alert("There will be an error")[1, 2].forEach(alert)
alert("Hello")[1, 2].forEach(alert);
```

But it should be two separate statements, not one. Such a merging in this case is just wrong, hence the error. This can happen in other situations.
Looks weird, right? Such merging in this case is just wrong. We need to put a semicolon after `alert` for the code to work correctly.

This can happen in other situations also.
````

We recommend putting semicolons between statements even if they are separated by newlines. This rule is widely adopted by the community. Let's note once again -- *it is possible* to leave out semicolons most of the time. But it's safer -- especially for a beginner -- to use them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ That's simple:
let ourPlanetName = "Earth";
```

Note, we could use a shorter name `planet`, but it might be not obvious what planet it refers to. It's nice to be more verbose. At least until the variable isNotTooLong.
Note, we could use a shorter name `planet`, but it might not be obvious what planet it refers to. It's nice to be more verbose. At least until the variable isNotTooLong.

## The name of the current visitor

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/05-types/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Special numeric values formally belong to the "number" type. Of course they are

We'll see more about working with numbers in the chapter <info:number>.

## BigInt
## BigInt [#bigint-type]

In JavaScript, the "number" type cannot represent integer values larger than <code>(2<sup>53</sup>-1)</code> (that's `9007199254740991`), or less than <code>-(2<sup>53</sup>-1)</code> for negatives. It's a technical limitation caused by their internal representation.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ true + false = 1
"$" + 4 + 5 = "$45"
"4" - 2 = 2
"4px" - 2 = NaN
7 / 0 = Infinity
" -9 " + 5 = " -9 5" // (3)
" -9 " - 5 = -14 // (4)
null + 1 = 1 // (5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ true + false
"$" + 4 + 5
"4" - 2
"4px" - 2
7 / 0
" -9 " + 5
" -9 " - 5
null + 1
Expand Down
23 changes: 16 additions & 7 deletions 1-js/02-first-steps/08-operators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,21 @@ alert( 8 % 3 ); // 2, a remainder of 8 divided by 3

### Exponentiation **

The exponentiation operator `a ** b` multiplies `a` by itself `b` times.
The exponentiation operator `a ** b` raises `a` to the power of `b`.

In school maths, we write that as a<sup>b</sup>.

For instance:

```js run
alert( 2 ** 2 ); // 4 (2 multiplied by itself 2 times)
alert( 2 ** 3 ); // 8 (2 * 2 * 2, 3 times)
alert( 2 ** 4 ); // 16 (2 * 2 * 2 * 2, 4 times)
alert( 2 ** 2 ); // 2² = 4
alert( 2 ** 3 ); // 2³ = 8
alert( 2 ** 4 ); // 2⁴ = 16
```

Mathematically, the exponentiation is defined for non-integer numbers as well. For example, a square root is an exponentiation by `1/2`:
Just like in maths, the exponentiation operator is defined for non-integer numbers as well.

For example, a square root is an exponentiation by ½:

```js run
alert( 4 ** (1/2) ); // 2 (power of 1/2 is the same as a square root)
Expand Down Expand Up @@ -104,7 +108,12 @@ Here's a more complex example:
alert(2 + 2 + '1' ); // "41" and not "221"
```

Here, operators work one after another. The first `+` sums two numbers, so it returns `4`, then the next `+` adds the string `1` to it, so it's like `4 + '1' = 41`.
Here, operators work one after another. The first `+` sums two numbers, so it returns `4`, then the next `+` adds the string `1` to it, so it's like `4 + '1' = '41'`.

```js run
alert('1' + 2 + 2); // "122" and not "14"
```
Here, the first operand is a string, the compiler treats the other two operands as strings too. The `2` gets concatenated to `'1'`, so it's like `'1' + 2 = "12"` and `"12" + 2 = "122"`.

The binary `+` is the only operator that supports strings in such a way. Other arithmetic operators work only with numbers and always convert their operands to numbers.

Expand Down Expand Up @@ -214,7 +223,7 @@ alert( x ); // 5

The fact of `=` being an operator, not a "magical" language construct has an interesting implication.

Most operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`.
All operators in JavaScript return a value. That's obvious for `+` and `-`, but also true for `=`.

The call `x = value` writes the `value` into `x` *and then returns it*.

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/10-ifelse/2-check-standard/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ importance: 2

Using the `if..else` construct, write the code which asks: 'What is the "official" name of JavaScript?'

If the visitor enters "ECMAScript", then output "Right!", otherwise -- output: "Didn't know? ECMAScript!"
If the visitor enters "ECMAScript", then output "Right!", otherwise -- output: "You don't know? ECMAScript!"

![](ifelse_task2.svg)

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/10-ifelse/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if (cond) {

## The "else" clause

The `if` statement may contain an optional "else" block. It executes when the condition is false.
The `if` statement may contain an optional "else" block. It executes when the condition is falsy.

For example:
```js run
Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/11-logical-operators/article.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Logical operators

There are three logical operators in JavaScript: `||` (OR), `&&` (AND), `!` (NOT).
There are four logical operators in JavaScript: `||` (OR), `&&` (AND), `!` (NOT), `??` (Nullish Coalescing). Here we cover the first three, the `??` operator is in the next article.

Although they are called "logical", they can be applied to values of any type, not only boolean. Their result can also be of any type.

Expand Down Expand Up @@ -64,7 +64,7 @@ if (hour < 10 || hour > 18 || isWeekend) {
}
```

## OR "||" finds the first truthy value
## OR "||" finds the first truthy value [#or-finds-the-first-truthy-value]

The logic described above is somewhat classical. Now, let's bring in the "extra" features of JavaScript.

Expand Down
33 changes: 18 additions & 15 deletions 1-js/02-first-steps/12-nullish-coalescing-operator/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

[recent browser="new"]

Here, in this article, we'll say that an expression is "defined" when it's neither `null` nor `undefined`.

The nullish coalescing operator is written as two question marks `??`.

As it treats `null` and `undefined` similarly, we'll use a special term here, in this article. We'll say that an expression is "defined" when it's neither `null` nor `undefined`.

The result of `a ?? b` is:
- if `a` is defined, then `a`,
- if `a` isn't defined, then `b`.


In other words, `??` returns the first argument if it's not `null/undefined`. Otherwise, the second one.

The nullish coalescing operator isn't anything completely new. It's just a nice syntax to get the first "defined" value of the two.
Expand All @@ -21,29 +20,31 @@ We can rewrite `result = a ?? b` using the operators that we already know, like
result = (a !== null && a !== undefined) ? a : b;
```

Now it should be absolutely clear what `??` does. Let's see where it helps.

The common use case for `??` is to provide a default value for a potentially undefined variable.

For example, here we show `Anonymous` if `user` isn't defined:
For example, here we show `user` if defined, otherwise `Anonymous`:

```js run
let user;

alert(user ?? "Anonymous"); // Anonymous
alert(user ?? "Anonymous"); // Anonymous (user not defined)
```

Of course, if `user` had any value except `null/undefined`, then we would see it instead:
Here's the example with `user` assigned to a name:

```js run
let user = "John";

alert(user ?? "Anonymous"); // John
alert(user ?? "Anonymous"); // John (user defined)
```

We can also use a sequence of `??` to select the first value from a list that isn't `null/undefined`.

Let's say we have a user's data in variables `firstName`, `lastName` or `nickName`. All of them may be undefined, if the user decided not to enter a value.
Let's say we have a user's data in variables `firstName`, `lastName` or `nickName`. All of them may be not defined, if the user decided not to enter a value.

We'd like to display the user name using one of these variables, or show "Anonymous" if all of them are undefined.
We'd like to display the user name using one of these variables, or show "Anonymous" if all of them aren't defined.

Let's use the `??` operator for that:

Expand Down Expand Up @@ -75,7 +76,7 @@ alert(firstName || lastName || nickName || "Anonymous"); // Supercoder
*/!*
```

The OR `||` operator exists since the beginning of JavaScript, so developers were using it for such purposes for a long time.
Historically, the OR `||` operator was there first. It exists since the beginning of JavaScript, so developers were using it for such purposes for a long time.

On the other hand, the nullish coalescing operator `??` was added to JavaScript only recently, and the reason for that was that people weren't quite happy with `||`.

Expand All @@ -96,16 +97,18 @@ alert(height || 100); // 100
alert(height ?? 100); // 0
```

- The `height || 100` checks `height` for being a falsy value, and it really is.
- so the result is the second argument, `100`.
- The `height || 100` checks `height` for being a falsy value, and it's `0`, falsy indeed.
- so the result of `||` is the second argument, `100`.
- The `height ?? 100` checks `height` for being `null/undefined`, and it's not,
- so the result is `height` "as is", that is `0`.

If the zero height is a valid value, that shouldn't be replaced with the default, then `??` does just the right thing.
In practice, the zero height is often a valid value, that shouldn't be replaced with the default. So `??` does just the right thing.

## Precedence

The precedence of the `??` operator is rather low: `5` in the [MDN table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table). So `??` is evaluated before `=` and `?`, but after most other operations, such as `+`, `*`.
The precedence of the `??` operator is about the same as `||`, just a bit lower. It equals `5` in the [MDN table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table), while `||` is `6`.

That means that, just like `||`, the nullish coalescing operator `??` is evaluated before `=` and `?`, but after most other operations, such as `+`, `*`.

So if we'd like to choose a value with `??` in an expression with other operators, consider adding parentheses:

Expand Down Expand Up @@ -139,7 +142,7 @@ The code below triggers a syntax error:
let x = 1 && 2 ?? 3; // Syntax error
```

The limitation is surely debatable, but it was added to the language specification with the purpose to avoid programming mistakes, when people start to switch to `??` from `||`.
The limitation is surely debatable, it was added to the language specification with the purpose to avoid programming mistakes, when people start to switch from `||` to `??`.

Use explicit parentheses to work around it:

Expand Down
17 changes: 14 additions & 3 deletions 1-js/02-first-steps/13-while-for/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ alert('Done!');

We need a way to stop the process if the user cancels the input.

The ordinary `break` after `input` would only break the inner loop. That's not sufficient--labels, come to the rescue!
The ordinary `break` after `input` would only break the inner loop. That's not sufficient -- labels, come to the rescue!

A *label* is an identifier with a colon before a loop:
```js
Expand Down Expand Up @@ -363,12 +363,23 @@ Labels do not allow us to jump into an arbitrary place in the code.

For example, it is impossible to do this:
```js
break label; // doesn't jumps to the label below
break label; // jump to the label below (doesn't work)

label: for (...)
```

A call to `break/continue` is only possible from inside a loop and the label must be somewhere above the directive.
A `break` directive must be inside a code block. Technically, any labelled code block will do, e.g.:
```js
label: {
// ...
break label; // works
// ...
}
```

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

A `continue` is only possible from inside a loop.
````

## Summary
Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/14-switch/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ switch (a) {
break;
*/!*
case 5:
alert( 'Too large' );
alert( 'Too big' );
break;
default:
alert( "I don't know such values" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ function checkAge(age) {
}
```

Note that the parentheses around `age > 18` are not required here. They exist for better readabilty.
Note that the parentheses around `age > 18` are not required here. They exist for better readability.
Loading