Skip to content

Commit 5744485

Browse files
committed
merging all conflicts
2 parents caf0939 + 035c526 commit 5744485

File tree

447 files changed

+8699
-3804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

447 files changed

+8699
-3804
lines changed

Diff for: .github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: iliakan

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ sftp-config.json
2121
Thumbs.db
2222

2323

24+
/svgs

Diff for: 1-js/01-getting-started/1-intro/article.md

+78
Large diffs are not rendered by default.

Diff for: 1-js/01-getting-started/2-manuals-specifications/article.md

+27
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,35 @@
22

33
ਇਹ ਕਿਤਾਬ ਇਕ * ਟਿਟੋਰਿਯਲ * ਹੈ. ਇਸਦਾ ਉਦੇਸ਼ ਤੁਹਾਨੂੰ ਹੌਲੀ ਹੌਲੀ ਭਾਸ਼ਾ ਸਿੱਖਣ ਵਿਚ ਸਹਾਇਤਾ ਕਰਨਾ ਹੈ. ਪਰ ਇਕ ਵਾਰ ਜਦੋਂ ਤੁਸੀਂ ਮੁਢਲੀਆਂ ਗੱਲਾਂ ਤੋਂ ਜਾਣੂ ਹੋਵੋਗੇ, ਤੁਹਾਨੂੰ ਹੋਰ ਸਰੋਤਾਂ ਦੀ ਜ਼ਰੂਰਤ ਹੋਏਗੀ.
44

5+
<<<<<<< HEAD
56
## ਨਿਰਧਾਰਨ
7+
=======
8+
This book is a *tutorial*. It aims to help you gradually learn the language. But once you're familiar with the basics, you'll need other resources.
9+
>>>>>>> 035c5267ba80fa7b55878f7213cbde449b4092d9
610
711
[ECMA-262 ਨਿਰਧਾਰਨ] (https://www.ecma-international.org/publications/standards/Ecma-262.htm) ਵਿੱਚ ਜਾਵਾ ਸਕ੍ਰਿਪਟ ਬਾਰੇ ਸਭ ਤੋਂ ਡੂੰਘਾਈ, ਵਿਸਥਾਰ ਅਤੇ ਰਸਮੀ ਜਾਣਕਾਰੀ ਹੈ. ਇਹ ਭਾਸ਼ਾ ਨੂੰ ਪਰਿਭਾਸ਼ਤ ਕਰਦਾ ਹੈ.
812

913
ਪਰ ਉਹ ਰਸਮੀ ਹੋਣ ਕਰਕੇ, ਪਹਿਲਾਂ ਸਮਝਣਾ ਮੁਸ਼ਕਲ ਹੈ. ਇਸ ਲਈ ਜੇ ਤੁਹਾਨੂੰ ਭਾਸ਼ਾ ਦੇ ਵੇਰਵਿਆਂ ਬਾਰੇ ਜਾਣਕਾਰੀ ਦੇ ਸਭ ਤੋਂ ਭਰੋਸੇਮੰਦ ਸਰੋਤ ਦੀ ਜ਼ਰੂਰਤ ਹੈ, ਤਾਂ ਨਿਰਧਾਰਨ ਸਹੀ ਜਗ੍ਹਾ ਹੈ. ਪਰ ਇਹ ਰੋਜ਼ਾਨਾ ਵਰਤੋਂ ਲਈ ਨਹੀਂ ਹੈ.
1014

1115
ਇੱਕ ਨਵਾਂ ਸਪੈਸੀਫਿਕੇਸ਼ਨ ਵਰਜ਼ਨ ਹਰ ਸਾਲ ਜਾਰੀ ਕੀਤਾ ਜਾਂਦਾ ਹੈ. ਇਨ੍ਹਾਂ ਰੀਲੀਜ਼ਾਂ ਦੇ ਵਿਚਕਾਰ, ਤਾਜ਼ਾ ਨਿਰਧਾਰਣ ਖਰੜਾ <https://tc39.es/ecma262/> 'ਤੇ ਹੈ.
1216

17+
<<<<<<< HEAD
1318
ਨਵੀਆਂ ਨਕੋਰ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਬਾਰੇ ਪੜ੍ਹਨ ਲਈ, ਜੋ "ਲਗਭਗ ਸਟੈਂਡਰਡ" (ਅਖੌਤੀ "ਪੜਾਅ 3") ਹਨ, <https://github.com/tc39/proposals> ਤੇ ਪ੍ਰਸਤਾਵ ਵੇਖੋ.
19+
=======
20+
A new specification version is released every year. Between these releases, the latest specification draft is at <https://tc39.es/ecma262/>.
21+
>>>>>>> 035c5267ba80fa7b55878f7213cbde449b4092d9
1422
1523
ਨਾਲ ਹੀ, ਜੇ ਤੁਸੀਂ ਬ੍ਰਾਜ਼ਰ ਲਈ ਡਵੈਲਪ ਕਰ ਰਹੇ ਹੋ, ਤਾਂ ਟਿਯੂਟੋਰਿਅਲ ਦੇ [ਦੂਜੇ ਭਾਗ] (ਜਾਣਕਾਰੀ: ਬਰਾਜ਼ਰ-ਵਾਤਾਵਰਣ) ਵਿਚ ਕਵਰ ਕੀਤੇ ਗਈ ਹੋਰ ਵੀ ਕਿਸਮਾਂ ਹਨ.
1624

25+
<<<<<<< HEAD
1726
## ਮੈਨੂਅਲ
27+
=======
28+
Also, if you're developing for the browser, then there are other specifications covered in the [second part](info:browser-environment) of the tutorial.
29+
>>>>>>> 035c5267ba80fa7b55878f7213cbde449b4092d9
1830
1931
- ** ਐਮਡੀਐਨ (ਮੋਜ਼ੀਲਾ) ਜਾਵਾ ਸਕ੍ਰਿਪਟ ਹਵਾਲਾ ** ਇੱਕ ਮੈਨੂਅਲ ਹੈ ਜੋ ਉਦਾਹਰਣਾਂ ਅਤੇ ਹੋਰ ਜਾਣਕਾਰੀ ਵਾਲਾ ਹੈ. ਵਿਅਕਤੀਗਤ ਭਾਸ਼ਾ ਦੇ ਕਾਰਜਾਂ, ਤਰੀਕਿਆਂ ਆਦਿ ਬਾਰੇ ਡੂੰਘਾਈ ਨਾਲ ਜਾਣਕਾਰੀ ਪ੍ਰਾਪਤ ਕਰਨਾ ਬਹੁਤ ਵਧੀਆ ਹੈ.
2032

33+
<<<<<<< HEAD
2134
ਕੋਈ ਇਸ ਨੂੰ <https://developer.mozilla.org/en-US/docs/Web/JavaScript/References> 'ਤੇ ਲੱਭ ਸਕਦਾ ਹੈ.
2235

2336
ਹਾਲਾਂਕਿ, ਇਸ ਦੀ ਬਜਾਏ ਇੰਟਰਨੈਟ ਦੀ ਵਰਤੋਂ ਕਰਨਾ ਅਕਸਰ ਵਧੀਆ ਹੁੰਦਾ ਹੈ. ਸਰਚ ਵਿੱਚ ਸਿਰਫ "ਐਮਡੀਐਨ + [ਸ਼ਬਦ]" ਦੀ ਵਰਤੋਂ ਕਰੋ, ਉਦਾ. <https://google.com/search?q=MDN+parseInt> `parseInt` ਫੰਕਸ਼ਨ ਦੀ ਭਾਲ ਕਰਨ ਲਈ.
@@ -26,16 +39,30 @@
2639
- ** ਐਮਐਸਡੀਐਨ ** - ਬਹੁਤ ਸਾਰੀ ਜਾਣਕਾਰੀ ਵਾਲਾ ਮਾਈਕ੍ਰੋਸਾੱਫਟ ਮੈਨੂਅਲ, ਜਿਸ ਵਿੱਚ ਜਾਵਾ ਸਕ੍ਰਿਪਟ (ਅਕਸਰ JScript ਵਜੋਂ ਜਾਣਿਆ ਜਾਂਦਾ ਹੈ) ਵੀ ਸ਼ਾਮਲ ਹੈ. ਜੇ ਕਿਸੇ ਨੂੰ ਇੰਟਰਨੈਟ ਐਕਸਪਲੋਰਰ ਲਈ ਕੁਝ ਖਾਸ ਦੀ ਜ਼ਰੂਰਤ ਹੈ, ਤਾਂ ਬਿਹਤਰ ਉਥੇ ਜਾਓ: <http://msdn.microsoft.com/>.
2740

2841
ਇਸ ਦੇ ਨਾਲ, ਅਸੀਂ "ਰੇਜੀਐਕਸਐਕਸ ਐਮਐਸਡੀਐਨ" ਜਾਂ "ਰੈਗੈਕਸ ਐਕਸਪ੍ਰੈਸ ਐਮਐਸਡੀਐਨ js ਸਕ੍ਰਿਪਟ" ਵਰਗੇ ਵਾਕਾਂ ਨਾਲ ਇੱਕ ਇੰਟਰਨੈਟ ਖੋਜ ਦੀ ਵਰਤੋਂ ਕਰ ਸਕਦੇ ਹਾਂ.
42+
=======
43+
- **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.
44+
45+
You can find it at <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.
46+
47+
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 the `parseInt` function.
48+
>>>>>>> 035c5267ba80fa7b55878f7213cbde449b4092d9
2949
3050
## ਅਨੁਕੂਲਤਾ ਟੇਬਲ
3151

3252
ਜਾਵਾ ਸਕ੍ਰਿਪਟ ਇੱਕ ਵਿਕਾਸਸ਼ੀਲ ਭਾਸ਼ਾ ਹੈ, ਨਵੀਆਂ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਨਿਯਮਿਤ ਤੌਰ ਤੇ ਸ਼ਾਮਲ ਕੀਤੀਆਂ ਜਾਂਦੀਆਂ ਹਨ.
3353

3454
ਬ੍ਰਾਜ਼ਰ-ਅਧਾਰਿਤ ਅਤੇ ਹੋਰ ਇੰਜਣਾਂ ਵਿਚਕਾਰ ਉਨ੍ਹਾਂ ਦਾ ਸਮਰਥਨ ਦੇਖਣ ਲਈ, ਵੇਖੋ:
3555

56+
<<<<<<< HEAD
3657
- <http://caniuse.com> - ਸਮਰਥਨ ਦੀਆਂ ਪ੍ਰਤੀ-ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਟੇਬਲ, ਉਦਾ. ਇਹ ਵੇਖਣ ਲਈ ਕਿ ਕਿਹੜਾ ਇੰਜਣ ਆਧੁਨਿਕ ਕ੍ਰਿਪਟੋਗ੍ਰਾਫੀ ਫੰਕਸ਼ਨਾਂ ਦਾ ਸਮਰਥਨ ਕਰਦੇ ਹਨ: <http://caniuse.com/#feat=cryptography>.
3758
- <https://kangax.github.io/compat-table> - ਭਾਸ਼ਾ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਅਤੇ ਇੰਜਣਾਂ ਵਾਲਾ ਇੱਕ ਟੇਬਲ ਜੋ ਉਹਨਾਂ ਦਾ ਸਮਰਥਨ ਕਰਦਾ ਹੈ ਜਾਂ ਸਮਰਥਨ ਨਹੀਂ ਕਰਦਾ.
3859

3960
ਇਹ ਸਾਰੇ ਸਰੋਤ ਅਸਲ-ਜੀਵਨ ਦੇ ਵਿਕਾਸ ਵਿੱਚ ਲਾਭਦਾਇਕ ਹਨ, ਕਿਉਂਕਿ ਉਨ੍ਹਾਂ ਵਿੱਚ ਭਾਸ਼ਾ ਦੇ ਵੇਰਵੇ, ਉਹਨਾਂ ਦੀ ਸਹਾਇਤਾ ਆਦਿ ਬਾਰੇ ਮਹੱਤਵਪੂਰਣ ਜਾਣਕਾਰੀ ਹੈ.
61+
=======
62+
- <https://caniuse.com> - per-feature tables of support, e.g. to see which engines support modern cryptography functions: <https://caniuse.com/#feat=cryptography>.
63+
- <https://kangax.github.io/compat-table> - a table with language features and engines that support those or don't support.
64+
65+
All these resources are useful in real-life development, as they contain valuable information about language details, their support, etc.
66+
>>>>>>> 035c5267ba80fa7b55878f7213cbde449b4092d9
4067
4168
ਕ੍ਰਿਪਾ ਕਰਕੇ ਉਨ੍ਹਾਂ (ਜਾਂ ਇਸ ਪੰਨੇ) ਨੂੰ ਉਨ੍ਹਾਂ ਮਾਮਲਿਆਂ ਲਈ ਯਾਦ ਰੱਖੋ ਜਦੋਂ ਤੁਹਾਨੂੰ ਕਿਸੇ ਵਿਸ਼ੇਸ਼ ਵਿਸ਼ੇਸ਼ਤਾ ਬਾਰੇ ਡੂੰਘਾਈ ਨਾਲ ਜਾਣਕਾਰੀ ਦੀ ਲੋੜ ਹੁੰਦੀ ਹੈ.

Diff for: 1-js/01-getting-started/3-code-editors/article.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212

1313
ਜੇ ਤੁਸੀਂ ਅਜੇ ਤੱਕ ਕੋਈ ਆਈਡੀਈ ਨਹੀਂ ਚੁਣਿਆ ਹੈ, ਹੇਠ ਦਿੱਤੇ ਵਿਕਲਪਾਂ 'ਤੇ ਗੌਰ ਕਰੋ:
1414

15+
<<<<<<< HEAD
1516
- [ਵਿਜ਼ੂਅਲ ਸਟੂਡੀਓ ਕੋਡ] (https://code.visualstudio.com/) (ਕਰਾਸ ਪਲੇਟਫਾਰਮ, ਮੁਫਤ).
1617
- [ਵੈਬਸਟਰਮ] (http://www.jetbrains.com/webstorm/) (ਕਰਾਸ ਪਲੇਟਫਾਰਮ, ਮੁਫਤ ਨਹੀਂ ਹੈ).
18+
=======
19+
- [Visual Studio Code](https://code.visualstudio.com/) (cross-platform, free).
20+
- [WebStorm](https://www.jetbrains.com/webstorm/) (cross-platform, paid).
21+
>>>>>>> 035c5267ba80fa7b55878f7213cbde449b4092d9
1722
1823
ਵਿੰਡੋਜ਼ ਲਈ, ਇੱਥੇ "ਵਿਜ਼ੂਅਲ ਸਟੂਡੀਓ" ਵੀ ਹੈ, "ਵਿਜ਼ੂਅਲ ਸਟੂਡੀਓ ਕੋਡ" ਨਾਲ ਕੰਫਯੁਜ ਨਾ ਹੋਣਾ. "ਵਿਜ਼ੂਅਲ ਸਟੂਡੀਓ" ਇੱਕ ਪੇਡ ਅਤੇ ਸ਼ਕਤੀਸ਼ਾਲੀ ਵਿੰਡੋਜ਼-ਕੇਵਲ ਸੰਪਾਦਕ ਹੈ, ਜੋ ਕਿ ਡੋਟ ਨੈਟ ਲਈ ਅਨੁਕੂਲ ਹੈ। ਇਹ ਜਾਵਾ ਸਕ੍ਰਿਪਟ ਲਈ ਵੀ ਵਧੀਆ ਹੈ। ਇੱਥੇ ਇੱਕ ਮੁਫਤ ਸੰਸਕਰਣ [ਵਿਜ਼ੂਅਲ ਸਟੂਡੀਓ ਕਮਿਨਿਟੀ] (https://www.visualstudio.com/vs/commune/) ਵੀ ਹੈ.
1924

@@ -29,18 +34,35 @@
2934

3035
ਅਭਿਆਸ ਵਿੱਚ, ਹਲਕੇ ਭਾਰ ਵਾਲੇ ਸੰਪਾਦਕਾਂ ਵਿੱਚ ਬਹੁਤ ਸਾਰੇ ਪਲੱਗਇਨ ਹੋ ਸਕਦੇ ਹਨ ਜਿਸ ਵਿੱਚ ਡਾਇਰੈਕਟਰੀ-ਪੱਧਰ ਦੇ ਸੰਟੈਕਸ ਵਿਸ਼ਲੇਸ਼ਕ ਅਤੇ ਆਟੋਮੈਟਿਕ ਪੂਰਨ ਸ਼ਾਮਲ ਹੁੰਦੇ ਹਨ, ਇਸ ਲਈ ਇੱਕ ਹਲਕੇ ਸੰਪਾਦਕ ਅਤੇ ਇੱਕ ਆਈਡੀਈ ਵਿੱਚ ਕੋਈ ਜਿਆਦਾ ਫਰਕ ਨਹੀਂ ਹੁੰਦਾ।
3136

37+
<<<<<<< HEAD
3238
ਹੇਠ ਲਿਖੀਆਂ ਚੋਣਾਂ ਤੁਹਾਡੇ ਧਿਆਨ ਦੇ ਹੱਕਦਾਰ ਹਨ:
3339

3440
- [ਐਟਮ] (https://atom.io/) (ਕਰਾਸ ਪਲੇਟਫਾਰਮ, ਮੁਫਤ).
3541
- [ਵਿਜ਼ੂਅਲ ਸਟੂਡੀਓ ਕੋਡ] (https://code.visualstudio.com/) (ਕਰਾਸ ਪਲੇਟਫਾਰਮ, ਮੁਫਤ).
3642
- [ਸ੍ਰੇਸ਼ਟ ਪਾਠ] (http://www.sublimetext.com) (ਕਰਾਸ ਪਲੇਟਫਾਰਮ, ਸ਼ੇਅਰਵੇਅਰ).
3743
- [ਨੋਟਪੈਡ ++] (https://notepad-plus-plus.org/) (ਵਿੰਡੋਜ਼, ਮੁਫਤ)
3844
- [ਵਿਮ] (http://www.vim.org/) ਅਤੇ [ਈਮੈਕਸ] (https://www.gnu.org/software/emacs/) ਵੀ ਸ਼ਾਨਦਾਰ ਹਨ ਜੇ ਤੁਸੀਂ ਉਨ੍ਹਾਂ ਦੀ ਵਰਤੋਂ ਕਰਨਾ ਜਾਣਦੇ ਹੋ.
45+
=======
46+
There are many options, for instance:
47+
48+
- [Sublime Text](https://www.sublimetext.com/) (cross-platform, shareware).
49+
- [Notepad++](https://notepad-plus-plus.org/) (Windows, free).
50+
- [Vim](https://www.vim.org/) and [Emacs](https://www.gnu.org/software/emacs/) are also cool if you know how to use them.
51+
>>>>>>> 035c5267ba80fa7b55878f7213cbde449b4092d9
3952
4053
## ਆਓ ਬਹਿਸ ਨਾ ਕਰੀਏ
4154

4255
ਉਪਰੋਕਤ ਸੂਚੀਆਂ ਵਿਚ ਸੰਪਾਦਕ ਉਹ ਹਨ ਜੋ ਜਾਂ ਤਾਂ ਮੈਂ ਜਾਂ ਮੇਰੇ ਦੋਸਤ ਜਿਨ੍ਹਾਂ ਨੂੰ ਮੈਂ ਚੰਗੇ ਡਿਵੈਲਪਰ ਮੰਨਦਾ ਹਾਂ ਲੰਬੇ ਸਮੇਂ ਤੋਂ ਇਸਤੇਮਾਲ ਕਰ ਰਹੇ ਹਨ ਅਤੇ ਖੁਸ਼ ਹਨ।
4356

4457
ਸਾਡੀ ਵੱਡੀ ਦੁਨੀਆ ਵਿਚ ਹੋਰ ਮਹਾਨ ਸੰਪਾਦਕ ਹਨ. ਕਿਰਪਾ ਕਰਕੇ ਉਸ ਨੂੰ ਚੁਣੋ ਜਿਸ ਨੂੰ ਤੁਸੀਂ ਸਭ ਤੋਂ ਵੱਧ ਪਸੰਦ ਕਰਦੇ ਹੋ.
4558

46-
ਕਿਸੇ ਸੰਦ ਦੀ ਤਰ੍ਹਾਂ ਸੰਪਾਦਕ ਦੀ ਚੋਣ ਵਿਅਕਤੀਗਤ ਹੈ ਅਤੇ ਤੁਹਾਡੇ ਪ੍ਰੋਜੈਕਟਾਂ, ਆਦਤਾਂ ਅਤੇ ਵਿਅਕਤੀਗਤ ਪਸੰਦਾਂ ਤੇ ਨਿਰਭਰ ਕਰਦੀ ਹੈ.
59+
<<<<<<< HEAD
60+
ਕਿਸੇ ਸੰਦ ਦੀ ਤਰ੍ਹਾਂ ਸੰਪਾਦਕ ਦੀ ਚੋਣ ਵਿਅਕਤੀਗਤ ਹੈ ਅਤੇ ਤੁਹਾਡੇ ਪ੍ਰੋਜੈਕਟਾਂ, ਆਦਤਾਂ ਅਤੇ ਵਿਅਕਤੀਗਤ ਪਸੰਦਾਂ ਤੇ ਨਿਰਭਰ ਕਰਦੀ ਹੈ.
61+
=======
62+
The choice of an editor, like any other tool, is individual and depends on your projects, habits, and personal preferences.
63+
64+
The author's personal opinion:
65+
66+
- I'd use [Visual Studio Code](https://code.visualstudio.com/) if I develop mostly frontend.
67+
- Otherwise, if it's mostly another language/platform and partially frontend, then consider other editors, such as XCode (Mac), Visual Studio (Windows) or Jetbrains family (Webstorm, PHPStorm, RubyMine etc, depending on the language).
68+
>>>>>>> 035c5267ba80fa7b55878f7213cbde449b4092d9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<body>
5+
6+
<script>
7+
alert( "I'm JavaScript!" );
8+
</script>
9+
10+
</body>
11+
12+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
[html src="index.html"]

Diff for: 1-js/02-first-steps/01-hello-world/article.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ So first, let's see how we attach a script to a webpage. For server-side environ
99

1010
## The "script" tag
1111

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

1414
For instance:
1515

@@ -46,7 +46,7 @@ The `<script>` tag contains JavaScript code which is automatically executed when
4646
The `<script>` tag has a few attributes that are rarely used nowadays but can still be found in old code:
4747

4848
The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code>
49-
: The old HTML standard, HTML4, required a script to have a `type`. Usually it was `type="text/javascript"`. It's not required anymore. Also, the modern HTML standard totally changed the meaning of this attribute. Now, it can be used for JavaScript modules. But that's an advanced topic; we'll talk about modules in another part of the tutorial.
49+
: The old HTML standard, HTML4, required a script to have a `type`. Usually it was `type="text/javascript"`. It's not required anymore. Also, the modern HTML standard totally changed the meaning of this attribute. Now, it can be used for JavaScript modules. But that's an advanced topic, we'll talk about modules in another part of the tutorial.
5050

5151
The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code>
5252
: This attribute was meant to show the language of the script. This attribute no longer makes sense because JavaScript is the default language. There is no need to use it.
@@ -73,12 +73,12 @@ Script files are attached to HTML with the `src` attribute:
7373
<script src="/path/to/script.js"></script>
7474
```
7575

76-
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.
76+
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.
7777

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

8080
```html
81-
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.2.0/lodash.js"></script>
81+
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
8282
```
8383

8484
To attach several scripts, use multiple tags:

Diff for: 1-js/02-first-steps/02-structure/article.md

+16-20
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ alert(3 +
4646
+ 2);
4747
```
4848

49-
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.
49+
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.
5050

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

@@ -56,40 +56,36 @@ Errors which occur in such cases are quite hard to find and fix.
5656
If you're curious to see a concrete example of such an error, check this code out:
5757
5858
```js run
59-
[1, 2].forEach(alert)
59+
alert("Hello");
60+
61+
[1, 2].forEach(alert);
6062
```
6163
62-
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`.
64+
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`.
6365
64-
Now, let's add an `alert` before the code and *not* finish it with a semicolon:
66+
Now let's remove the semicolon after the `alert`:
6567
6668
```js run no-beautify
67-
alert("There will be an error")
69+
alert("Hello")
6870
69-
[1, 2].forEach(alert)
71+
[1, 2].forEach(alert);
7072
```
7173
72-
Now if we run the code, only the first `alert` is shown and then we have an error!
73-
74-
But everything is fine again if we add a semicolon after `alert`:
75-
```js run
76-
alert("All fine now");
74+
The difference compared to the code above is only one character: the semicolon at the end of the first line is gone.
7775
78-
[1, 2].forEach(alert)
79-
```
76+
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.
8077
81-
Now we have the "All fine now" message followed by `1` and `2`.
78+
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.
8279
83-
84-
The error in the no-semicolon variant occurs because JavaScript does not assume a semicolon before square brackets `[...]`.
85-
86-
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:
80+
Here's how the engine sees it:
8781
8882
```js run no-beautify
89-
alert("There will be an error")[1, 2].forEach(alert)
83+
alert("Hello")[1, 2].forEach(alert);
9084
```
9185
92-
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.
86+
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.
87+
88+
This can happen in other situations also.
9389
````
9490

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

0 commit comments

Comments
 (0)