Skip to content

Commit 6ba17e1

Browse files
committed
merging all conflicts
2 parents faeb69b + a829155 commit 6ba17e1

File tree

764 files changed

+20448
-11302
lines changed

Some content is hidden

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

764 files changed

+20448
-11302
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto eol=lf
2+
*.svg binary

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ sftp-config.json
2121
Thumbs.db
2222

2323

24+
/svgs

1-js/01-getting-started/1-intro/article.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# An Introduction to JavaScript
22

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

55
## What is JavaScript?
66

7-
*JavaScript* was initially created to *"make web pages alive"*.
7+
*JavaScript* was initially created to "make web pages alive".
88

99
The programs in this language are called *scripts*. They can be written right in a web page's HTML and run automatically as the page loads.
1010

1111
Scripts are provided and executed as plain text. They don't need special preparation or compilation to run.
1212

1313
In this aspect, JavaScript is very different from another language called [Java](https://en.wikipedia.org/wiki/Java_(programming_language)).
1414

15-
```smart header="Why <u>Java</u>Script?"
15+
```smart header="Why is it called <u>Java</u>Script?"
1616
When JavaScript was created, it initially had another name: "LiveScript". But Java was very popular at that time, so it was decided that positioning a new language as a "younger brother" of Java would help.
1717
1818
But as it evolved, JavaScript became a fully independent language with its own specification called [ECMAScript](http://en.wikipedia.org/wiki/ECMAScript), and now it has no relation to Java at all.
@@ -24,11 +24,11 @@ The browser has an embedded engine sometimes called a "JavaScript virtual machin
2424

2525
Different engines have different "codenames". For example:
2626

27-
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome and Opera.
27+
- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome, Opera and Edge.
2828
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- in Firefox.
29-
- ...There are other codenames like "Trident" and "Chakra" for different versions of IE, "ChakraCore" for Microsoft Edge, "Nitro" and "SquirrelFish" for Safari, etc.
29+
- ...There are other codenames like "Chakra" for IE, "JavaScriptCore", "Nitro" and "SquirrelFish" for Safari, etc.
3030

31-
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.
31+
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.
3232

3333
```smart header="How do engines work?"
3434
@@ -38,7 +38,7 @@ Engines are complicated. But the basics are easy.
3838
2. Then it converts ("compiles") the script to the machine language.
3939
3. And then the machine code runs, pretty fast.
4040
41-
The engine applies optimizations at each step of the process. It even watches the compiled script as it runs, analyzes the data that flows through it, and applies optimizations to the machine code based on that knowledge. When it's done, scripts run quite fast.
41+
The engine applies optimizations at each step of the process. It even watches the compiled script as it runs, analyzes the data that flows through it, and further optimizes the machine code based on that knowledge.
4242
```
4343

4444
## What can in-browser JavaScript do?
@@ -59,11 +59,11 @@ For instance, in-browser JavaScript is able to:
5959

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

62-
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.
62+
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.
6363

6464
Examples of such restrictions include:
6565

66-
- JavaScript on a webpage may not read/write arbitrary files on the hard disk, copy them or execute programs. It has no direct access to OS system functions.
66+
- JavaScript on a webpage may not read/write arbitrary files on the hard disk, copy them or execute programs. It has no direct access to OS functions.
6767

6868
Modern browsers allow it to work with files, but the access is limited and only provided if the user does certain actions, like "dropping" a file into a browser window or selecting it via an `<input>` tag.
6969

@@ -86,14 +86,13 @@ There are at least *three* great things about JavaScript:
8686
```compare
8787
+ Full integration with HTML/CSS.
8888
+ Simple things are done simply.
89-
+ Support by all major browsers and enabled by default.
89+
+ Supported by all major browsers and enabled by default.
9090
```
9191
JavaScript is the only browser technology that combines these three things.
9292

9393
That's what makes JavaScript unique. That's why it's the most widespread tool for creating browser interfaces.
9494

95-
While planning to learn a new technology, it's beneficial to check its perspectives. So let's move on to the modern trends affecting it, including new languages and browser abilities.
96-
95+
That said, JavaScript also allows to create servers, mobile applications, etc.
9796

9897
## Languages "over" JavaScript
9998

@@ -109,12 +108,15 @@ Examples of such languages:
109108

110109
- [CoffeeScript](http://coffeescript.org/) is a "syntactic sugar" for JavaScript. It introduces shorter syntax, allowing us to write clearer and more precise code. Usually, Ruby devs like it.
111110
- [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.
112-
- [Dart](https://www.dartlang.org/) is a standalone language that has its own engine that runs in non-browser environments (like mobile apps). It was initially offered by Google as a replacement for JavaScript, but as of now, browsers require it to be transpiled to JavaScript just like the ones above.
111+
- [Flow](http://flow.org/) also adds data typing, but in a different way. Developed by Facebook.
112+
- [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.
113+
- [Brython](https://brython.info/) is a Python transpiler to JavaScript that enables the writing of applications in pure Python without JavaScript.
114+
- [Kotlin](https://kotlinlang.org/docs/reference/js-overview.html) is a modern, concise and safe programming language that can target the browser or Node.
113115

114-
There are more. Of course, even if we use one of these languages, we should also know JavaScript to really understand what we're doing.
116+
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.
115117

116118
## Summary
117119

118-
- JavaScript was initially created as a browser-only language, but is now used in many other environments as well.
119-
- Today, JavaScript has a unique position as the most widely-adopted browser language with full integration with HTML/CSS.
120+
- JavaScript was initially created as a browser-only language, but it is now used in many other environments as well.
121+
- Today, JavaScript has a unique position as the most widely-adopted browser language, fully integrated with HTML/CSS.
120122
- 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.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
# Manuals and specifications
3+
4+
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 sources.
5+
6+
## Specification
7+
8+
[The ECMA-262 specification](https://www.ecma-international.org/publications/standards/Ecma-262.htm) contains the most in-depth, detailed and formalized information about JavaScript. It defines the language.
9+
10+
But being that formalized, it's difficult to understand at first. So if you need the most trustworthy source of information about the language details, the specification is the right place. But it's not for everyday use.
11+
12+
A new specification version is released every year. In-between these releases, the latest specification draft is at <https://tc39.es/ecma262/>.
13+
14+
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>.
15+
16+
Also, if you're developing for the browser, then there are other specifications covered in the [second part](info:browser-environment) of the tutorial.
17+
18+
## Manuals
19+
20+
- **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.
21+
22+
One can find it at <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference>.
23+
24+
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.
25+
26+
## Compatibility tables
27+
28+
JavaScript is a developing language, new features get added regularly.
29+
30+
To see their support among browser-based and other engines, see:
31+
32+
- <http://caniuse.com> - per-feature tables of support, e.g. to see which engines support modern cryptography functions: <http://caniuse.com/#feat=cryptography>.
33+
- <https://kangax.github.io/compat-table> - a table with language features and engines that support those or don't support.
34+
35+
All these resources are useful in real-life development, as they contain valuable information about language details, their support etc.
36+
37+
Please remember them (or this page) for the cases when you need in-depth information about a particular feature.

1-js/01-getting-started/2-code-editors/article.md renamed to 1-js/01-getting-started/3-code-editors/article.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ An IDE loads the project (which can be many files), allows navigation between fi
1212

1313
If you haven't selected an IDE yet, consider the following options:
1414

15-
- [WebStorm](http://www.jetbrains.com/webstorm/) for frontend development. The same company offers other editors for other languages (paid).
16-
- [Netbeans](http://netbeans.org/) (free).
15+
- [Visual Studio Code](https://code.visualstudio.com/) (cross-platform, free).
16+
- [WebStorm](http://www.jetbrains.com/webstorm/) (cross-platform, paid).
1717

18-
All of these IDEs are cross-platform.
18+
For Windows, there's also "Visual Studio", not to be confused with "Visual Studio Code". "Visual Studio" is a paid and mighty Windows-only editor, well-suited for the .NET platform. It's also good at JavaScript. There's also a free version [Visual Studio Community](https://www.visualstudio.com/vs/community/).
1919

20-
For Windows, there's also "Visual Studio", not to be confused with "Visual Studio Code." "Visual Studio" is a paid and mighty Windows-only editor, well-suited for the .NET platform. A free version of it is called [Visual Studio Community](https://www.visualstudio.com/vs/community/).
21-
22-
Many IDEs are paid but have a trial period. Their cost is usually negligible compared to a qualified developer's salary, so just choose the best one for you.
20+
Many IDEs are paid, but have a trial period. Their cost is usually negligible compared to a qualified developer's salary, so just choose the best one for you.
2321

2422
## Lightweight editors
2523

@@ -33,21 +31,11 @@ In practice, lightweight editors may have a lot of plugins including directory-l
3331

3432
The following options deserve your attention:
3533

36-
- [Visual Studio Code](https://code.visualstudio.com/) (cross-platform, free) also has many IDE-like features.
3734
- [Atom](https://atom.io/) (cross-platform, free).
3835
- [Sublime Text](http://www.sublimetext.com) (cross-platform, shareware).
3936
- [Notepad++](https://notepad-plus-plus.org/) (Windows, free).
4037
- [Vim](http://www.vim.org/) and [Emacs](https://www.gnu.org/software/emacs/) are also cool if you know how to use them.
4138

42-
## My favorites
43-
44-
The personal preference of the author is to have both an IDE for projects and a lightweight editor for quick and easy file editing.
45-
46-
I'm using:
47-
48-
- As an IDE for JS -- [WebStorm](http://www.jetbrains.com/webstorm/) (I switch to one of the other JetBrains offerings when using other languages)
49-
- As a lightweight editor -- [Sublime Text](http://www.sublimetext.com) or [Atom](https://atom.io/).
50-
5139
## Let's not argue
5240

5341
The editors in the lists above are those that either I or my friends whom I consider good developers have been using for a long time and are happy with.
-105 KB
Binary file not shown.
Binary file not shown.

1-js/01-getting-started/3-devtools/article.md renamed to 1-js/01-getting-started/4-devtools/article.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,15 @@ The exact look of developer tools depends on your version of Chrome. It changes
2929
- Here we can see the red-colored error message. In this case, the script contains an unknown "lalala" command.
3030
- On the right, there is a clickable link to the source `bug.html:12` with the line number where the error has occurred.
3131

32-
Below the error message, there is a blue `>` symbol. It marks a "command line" where we can type JavaScript commands. Press `key:Enter` to run them (`key:Shift+Enter` to input multi-line commands).
32+
Below the error message, there is a blue `>` symbol. It marks a "command line" where we can type JavaScript commands. Press `key:Enter` to run them.
3333

3434
Now we can see errors, and that's enough for a start. We'll come back to developer tools later and cover debugging more in-depth in the chapter <info:debugging-chrome>.
3535

36+
```smart header="Multi-line input"
37+
Usually, when we put a line of code into the console, and then press `key:Enter`, it executes.
38+
39+
To insert multiple lines, press `key:Shift+Enter`. This way one can enter long fragments of JavaScript code.
40+
```
3641

3742
## Firefox, Edge, and others
3843

@@ -50,12 +55,6 @@ Open Preferences and go to the "Advanced" pane. There's a checkbox at the bottom
5055

5156
Now `key:Cmd+Opt+C` can toggle the console. Also, note that the new top menu item named "Develop" has appeared. It has many commands and options.
5257

53-
## Multi-line input
54-
55-
Usually, when we put a line of code into the console, and then press `key:Enter`, it executes.
56-
57-
To insert multiple lines, press `key:Shift+Enter`.
58-
5958
## Summary
6059

6160
- Developer tools allow us to see errors, run commands, examine variables, and much more.
107 KB
Loading
Loading
Lines changed: 12 additions & 0 deletions
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>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
[html src="index.html"]

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Hello, world!
22

3-
This part of the tutorial is about core JavaScript, the language itself. Later on, you'll learn about Node.js and other platforms that use it.
3+
This part of the tutorial is about core JavaScript, the language itself.
44

55
But we need a working environment to run our scripts and, since this book is online, the browser is a good choice. We'll keep the amount of browser-specific commands (like `alert`) to a minimum so that you don't spend time on them if you plan to concentrate on another environment (like Node.js). We'll focus on JavaScript in the browser in the [next part](/ui) of the tutorial.
66

@@ -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, HTML5, 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.
@@ -60,7 +60,7 @@ Comments before and after scripts.
6060
//--></script>
6161
```
6262

63-
This trick isn't used in modern JavaScript. These comments hid JavaScript code from old browsers that didn't know how to process the `<script>` tag. Since browsers released in the last 15 years don't have this issue, this kind of comment can help you identify really old code.
63+
This trick isn't used in modern JavaScript. These comments hide JavaScript code from old browsers that didn't know how to process the `<script>` tag. Since browsers released in the last 15 years don't have this issue, this kind of comment can help you identify really old code.
6464

6565

6666
## External scripts
@@ -73,14 +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 file (from the site root).
77-
78-
You 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.
7977

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

8280
```html
83-
<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>
8482
```
8583

8684
To attach several scripts, use multiple tags:

0 commit comments

Comments
 (0)