Skip to content

Commit 05a93ce

Browse files
committed
edit
1 parent e78e527 commit 05a93ce

File tree

212 files changed

+3202
-3957
lines changed

Some content is hidden

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

212 files changed

+3202
-3957
lines changed

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

Lines changed: 58 additions & 80 deletions
Large diffs are not rendered by default.
Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
# Using the latest features now
2+
# Using the latest features now
33

44
The [latest standard](http://www.ecma-international.org/publications/standards/Ecma-262.htm) was approved in June 2015.
55

6-
As it includes a lot of new features, most browsers implement them partially. You can find the current state of the support at [](https://kangax.github.io/compat-table/es6/).
6+
As it includes a lot of new features, most browsers implement them partially. You can find the current state of the support at <https://kangax.github.io/compat-table/es6/>.
77

88
## Single-engine app
99

@@ -13,7 +13,7 @@ Most notably, V8 supports many of the new features only if the code is running i
1313

1414
You will find most code in this tutorial using this directive and, because of that, runnable in Chrome.
1515

16-
But what if we're writing a cross-browser application? Different browsers support different subsets of ES-2015.
16+
But what if we're writing a cross-browser application? Different browsers support different subsets of ES-2015.
1717

1818
Here comes Babel.JS.
1919

@@ -23,30 +23,27 @@ Here comes Babel.JS.
2323

2424
Actually, there are two parts in Babel:
2525

26-
<ol>
27-
<li>The transpiler program, which rewrites the code.
26+
1. The transpiler program, which rewrites the code.
2827

29-
The transpiler runs on a developer's computer. It rewrites the code, which is then bundled by a project build system (like [webpack](http://webpack.github.io/) or [brunch](http://brunch.io/)). Most build systems can support Babel easily. One just needs to setup the build system itself.</li>
30-
<li>JavaScript library.
28+
The transpiler runs on a developer's computer. It rewrites the code, which is then bundled by a project build system (like [webpack](http://webpack.github.io/) or [brunch](http://brunch.io/)). Most build systems can support Babel easily. One just needs to setup the build system itself.
29+
2. JavaScript library.
3130

32-
An additional JavaScript library with modern JavaScript functions for the browsers that do not have them built-in (yet). The library must be attached to each webpage which relies on these functions.</li>
33-
</ol>
31+
An additional JavaScript library with modern JavaScript functions for the browsers that do not have them built-in (yet). The library must be attached to each webpage which relies on these functions.
3432

3533
There is a special "play" mode of Babel.JS which merges both parts in a single in-browser script.
3634

3735
The usage looks like this:
3836

39-
```html
40-
<!--+ run -->
37+
```html run
4138
*!*
4239
<!-- browser.js is on my server please don't hotlink -->
4340
<script src="https://en.js.cx/babel-core/browser.min.js"></script>
4441
*/!*
4542

4643
<script type="text/babel">
47-
let arr = ["hello", 2];
44+
let arr = ["hello", 2];
4845
49-
let [str, times] = arr;
46+
let [str, times] = arr;
5047
5148
alert( str.repeat(times) ); // hellohello
5249
</script>
@@ -57,16 +54,15 @@ Script `browser.min.js` is attached to the top of the page. It automatically tra
5754
The size of `browser.min.js` is above 1 megabyte, because it includes the transpiler. Hence such usage is only for "playing" and not recommended for production.
5855

5956
Also:
60-
<ul>
61-
<li>There is a "try it" page on [](https://babeljs.io/repl/) which allows to run snippets of code.</li>
62-
<li>[JSBin](http://jsbin.com) allows to use "ES6/Babel" mode for JS, see [this snippet](http://jsbin.com/daxihelolo/edit?js,output) as an example.</li>
63-
</ul>
57+
58+
- There is a "try it" page on <https://babeljs.io/repl/> which allows to run snippets of code.
59+
- [JSBin](http://jsbin.com) allows to use "ES6/Babel" mode for JS, see [this snippet](http://jsbin.com/daxihelolo/edit?js,output) as an example.
6460

6561
# Examples on this site
6662

67-
[warn header="Browser support is required"]
63+
```warn header="Browser support is required"
6864
Examples that use ES-2015 will work only if your browser supports it.
69-
[/warn]
65+
```
7066

7167
Sometimes it means that when running an example in a non-supporting browser, an error is shown.
7268

@@ -80,7 +76,7 @@ And even if your browser does not support some code, you can run it through Babe
8076

8177
That would be fine, because on production everyone's using Babel anyway.
8278

83-
Once again, let's note that the most up-to-date situation with support is reflected on [](https://kangax.github.io/compat-table/es6/).
79+
Once again, let's note that the most up-to-date situation with support is reflected on <https://kangax.github.io/compat-table/es6/>.
8480

8581
Now we can go coding, but we need a good code editor for that. That is discussed in the next session.
8682

1-js/1-getting-started/3-editor/article.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ For the comfortable development we need a good code editor.
44

55
It should support at least:
66

7-
<ol>
8-
<li>Syntax highlight.</li>
9-
<li>Autocompletion.</li>
10-
<li>Folding -- collapsing/opening blocks of code.</li>
11-
<li>...the more features -- the better.</li>
12-
</ol>
7+
1. Syntax highlight.
8+
2. Autocompletion.
9+
3. Folding -- collapsing/opening blocks of code.
10+
4. ...the more features -- the better.
1311

1412
[cut]
1513

@@ -21,13 +19,11 @@ An IDE operates on a "whole project": loads it and then can navigate between fil
2119

2220
If you haven't considered selecting an IDE, pleae look at the following variants:
2321

24-
<ul>
25-
<li>IntelliJ editors: [WebStorm](http://www.jetbrains.com/webstorm/) for frontend development and [PHPStorm (PHP)](http://www.jetbrains.com/phpstorm/), [IDEA (Java)](http://www.jetbrains.com/idea/), [RubyMine (Ruby)](http://www.jetbrains.com/ruby/) and other if you need additional languages.</li>
26-
<li>Visual Studio is fine if you're a .NET developer.</li>
27-
<li>Eclipse-based products, like [Aptana](http://www.aptana.com/) and Zend Studio.</li>
28-
<li>[Komodo IDE](http://www.activestate.com/komodo-ide) and it's lightweight free version [Komodo Edit](http://www.activestate.com/komodo-edit).</li>
29-
<li>[Netbeans](http://netbeans.org/)</li>
30-
</ul>
22+
- IntelliJ editors: [WebStorm](http://www.jetbrains.com/webstorm/) for frontend development and [PHPStorm (PHP)](http://www.jetbrains.com/phpstorm/), [IDEA (Java)](http://www.jetbrains.com/idea/), [RubyMine (Ruby)](http://www.jetbrains.com/ruby/) and other if you need additional languages.
23+
- Visual Studio is fine if you're a .NET developer.
24+
- Eclipse-based products, like [Aptana](http://www.aptana.com/) and Zend Studio.
25+
- [Komodo IDE](http://www.activestate.com/komodo-ide) and it's lightweight free version [Komodo Edit](http://www.activestate.com/komodo-edit).
26+
- [Netbeans](http://netbeans.org/)
3127

3228
All of them with the exception of Visual Studio are cross-platform.
3329

@@ -45,22 +41,19 @@ In practice, "lightweight" editors may have a lot of plugins including directory
4541

4642
The following options deserve your attention:
4743

48-
<ul>
49-
<li><a href="http://www.sublimetext.com">Sublime Text</a> (cross-platform, shareware).</li>
50-
<li><a href="https://atom.io/">Atom</a> (cross-platform, free).</li>
51-
<li><a href="http://sourceforge.net/projects/notepad-plus/">Notepad++</a> (Windows, free).</li>
52-
<li>Vim, Emacs are cool. If you know how to use them.</li>
53-
</ul>
44+
- <a href="http://www.sublimetext.com">Sublime Text</a> (cross-platform, shareware).
45+
- <a href="https://atom.io/">Atom</a> (cross-platform, free).
46+
- <a href="http://sourceforge.net/projects/notepad-plus/">Notepad++</a> (Windows, free).
47+
- Vim, Emacs are cool. If you know how to use them.
5448

5549
## My favorites
5650

5751
I believe one should have both an IDE for projects and a lightweight editor for quick and easy file editing.
5852

5953
I'm using:
60-
<ul>
61-
<li>[WebStorm](http://www.jetbrains.com/webstorm/) for JS, and if there is one more language in the project, then I switch to other Jetbrains editors like [PHPStorm](http://www.jetbrains.com/phpstorm/) (PHP), [IDEA](http://www.jetbrains.com/idea/) (Java), [RubyMine](http://www.jetbrains.com/ruby/) (Ruby). There are editors for other languages too, but I didn't use them.</li>
62-
<li>As a lightweight editor -- <a href="http://www.sublimetext.com">Sublime Text</a>.</li>
63-
</ul>
54+
55+
- [WebStorm](http://www.jetbrains.com/webstorm/) for JS, and if there is one more language in the project, then I switch to other Jetbrains editors like [PHPStorm](http://www.jetbrains.com/phpstorm/) (PHP), [IDEA](http://www.jetbrains.com/idea/) (Java), [RubyMine](http://www.jetbrains.com/ruby/) (Ruby). There are editors for other languages too, but I didn't use them.
56+
- As a lightweight editor -- <a href="http://www.sublimetext.com">Sublime Text</a>.
6457

6558
If you don't know what to choose -- you can consider these ones.
6659

1-js/1-getting-started/4-devtools/article.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,53 +20,48 @@ Developer tools are really powerful, there are many features, but on this stage
2020

2121
[cut]
2222

23-
## Google Chrome
23+
## Google Chrome
2424

25-
Open the page [bug.html](bug.html).
25+
Open the page [bug.html](bug.html).
2626

2727
There's an error in the JavaScript code on it. An ordinary visitor won't see it, so let's open developer tools.
2828

29-
Press the key [key F12] or, if you're on Mac, then [key Cmd+Opt+J].
29+
Press the key `key:F12` or, if you're on Mac, then `key:Cmd+Opt+J`.
3030

3131
The developer tools will open on the Console tab by default.
3232

3333
It looks somewhat like this:
3434

35-
<img src="chrome.png">
35+
![](chrome.png)
3636

3737
The exact look depends on your Chrome version. It changes from time to time, but should be similar.
3838

39-
<ul>
40-
<li>Here we can see the red-colored error message. In this case the script contains a "lalala" command, which was put there just because it is unknown.</li>
41-
<li>On the right, there is a clickable link to the source `bug.html:12` with the line number where the error has occured.</li>
42-
</ul>
39+
- Here we can see the red-colored error message. In this case the script contains a "lalala" command, which was put there just because it is unknown.
40+
- On the right, there is a clickable link to the source `bug.html:12` with the line number where the error has occured.
4341

44-
Below the error message there is a blue `>` symbol. It marks a "command line" where we can type JavaScript commands and press enter to run them ([key Shift+Enter] to input multiline commands).
42+
Below the error message there is a blue `>` symbol. It marks a "command line" where we can type JavaScript commands and press enter to run them (`key:Shift+Enter` to input multiline commands).
4543

46-
Now we can see errors and that's enough for the start. We'll be back to developer tools later and cover debugging more in-depth in the chapter [](/debugging-chrome).
44+
Now we can see errors and that's enough for the start. We'll be back to developer tools later and cover debugging more in-depth in the chapter <info:debugging-chrome>.
4745

4846
## Safari
4947

5048
For Safari, we need to enable the "Develop menu" first.
5149

5250
There's a checkbox for that at the bottom of the "Advanced" pane of the preferences:
5351

54-
<img src="safari.png">
52+
![](safari.png)
5553

56-
Now [key Cmd+Opt+C] can toggle the console. Also note that the new top menu item has appeared with many useful options.
54+
Now `key:Cmd+Opt+C` can toggle the console. Also note that the new top menu item has appeared with many useful options.
5755

5856
## Other browsers
5957

60-
Most other browsers use [key F12] to open developer tools.
58+
Most other browsers use `key:F12` to open developer tools.
6159

6260
The look & feel of them is quite similar, once we know how to use one of them (can start with Chrome), can easily switch to another.
6361

6462
## Summary
6563

66-
<ul>
67-
<li>Developer tools allow us to see errors, run commands, examine variables and much more.</li>
68-
<li>They can be opened with [key F12] for most browsers under Windows. Chrome for Mac needs [key Cmd+Opt+J], Safari: [key Cmd+Opt+C] (need to enable first).
69-
</li>
70-
</ul>
64+
- Developer tools allow us to see errors, run commands, examine variables and much more.
65+
- They can be opened with `key:F12` for most browsers under Windows. Chrome for Mac needs `key:Cmd+Opt+J`, Safari: `key:Cmd+Opt+C` (need to enable first).
7166

7267
Now we have the environment ready. In the next section we get down to JavaScript.
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
# Show an alert
1+
importance: 5
2+
3+
---
24

3-
[importance 5]
5+
# Show an alert
46

57
Create a page that shows a message "I'm JavaScript!".
68

79
Do it in a sandbox, or on your hard drive, doesn't matter, just ensure that it works.
810

911
[demo src="solution"]
12+

1-js/2-first-steps/1-hello-world/article.md

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
In this chapter we'll create a simple script and see it working.
44

55
[cut]
6+
67
## The "script" tag
78

8-
[smart header="What if I want to move faster?"]
9-
In the case if the reader of these lines has developed with JavaScript already or has a lot of experience in another language, he can skip detailed explanatins and jump to [](/javascript-specials). There he can find an essense of important features.
9+
```smart header="What if I want to move faster?"
10+
In the case if the reader of these lines has developed with JavaScript already or has a lot of experience in another language, he can skip detailed explanatins and jump to <info:javascript-specials>. There he can find an essense of important features.
1011
1112
If you have enough time and want to learn things in details then read on :)
12-
[/smart]
13+
```
1314

1415
JavaScript programs can be inserted in any place of HTML with the help of the `<script>` tag.
1516

1617
For instance:
1718

18-
```html
19-
<!--+ run height=100 -->
19+
```html run height=100
2020
<!DOCTYPE HTML>
2121
<html>
2222

@@ -37,57 +37,48 @@ For instance:
3737
</html>
3838
```
3939

40-
[online]
40+
```online
4141
You can run the example clicking on a "Play" button in it's right-top corner.
42-
[/online]
42+
```
4343

4444
The `<script>` tag contains JavaScript code which is automatically executed when the browser meets the tag.
4545

4646
Please note the execution sequence:
4747

48-
<ol>
49-
<li>Browser starts to parse the document and display the page.</li>
50-
<li>When the browser meets `<script>`, it switches to the JavaScript execution mode. In this mode it executes the script.</li>
51-
<li>The `alert` command shows a message and pauses the execution.</li>
52-
<li>*Note that a part of the page before the script is shown already at this moment.*</li>
53-
<li>When the script is finished, it gets back to the HTML-mode, and *only then* it shows the rest of the document.</li>
54-
</ol>
48+
1. Browser starts to parse the document and display the page.
49+
2. When the browser meets `<script>`, it switches to the JavaScript execution mode. In this mode it executes the script.
50+
3. The `alert` command shows a message and pauses the execution.
51+
4. *Note that a part of the page before the script is shown already at this moment.*
52+
5. When the script is finished, it gets back to the HTML-mode, and *only then* it shows the rest of the document.
5553

5654
A visitor won't see the content after the script until it is executed. In other words, a `<script>` tag blocks rendering.
5755

58-
5956
## The modern markup
6057

6158
In the past, `<script>` had a few necessary attributes.
6259

6360
We can find the following in the old code:
6461

65-
<dl>
66-
<dt>The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code></dt>
62+
The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code>
6763

68-
<dd>The old standard HTML4 required a script to have the type. Usually it was `type="text/javascript"`. The modern HTML standard assumes this `type` by default, no attribute is required.
69-
</dd>
64+
: The old standard HTML4 required a script to have the type. Usually it was `type="text/javascript"`. The modern HTML standard assumes this `type` by default, no attribute is required.
7065

71-
<dt>The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code></dt>
72-
<dd>This attribute was meant to show the language of the script. As of now, this attribute makes no sense, the language is JavaScript by default. No need to use it.</dd>
73-
<dt>Comments before and after scripts.</dt>
74-
<dd>In really ancient books and guides, one may find comments inside `<script>`, like this:
66+
The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code>
67+
: This attribute was meant to show the language of the script. As of now, this attribute makes no sense, the language is JavaScript by default. No need to use it.
7568

76-
```html
77-
<!--+ no-beautify -->
78-
<script type="text/javascript"><!--
79-
...
80-
//--></script>
81-
```
69+
Comments before and after scripts.
70+
: In really ancient books and guides, one may find comments inside `<script>`, like this:
71+
72+
```html no-beautify
73+
<script type="text/javascript"><!--
74+
...
75+
//--></script>
76+
```
8277

83-
These comments were supposed to hide the code from an old browser that did't understand a `<script>` tag. But all browsers born in the past 15 years know about `<script>`, so that's not an issue. So if you see such code somewhere you know the guide is really old and probably not worth looking into.
84-
</dd>
85-
</dl>
78+
These comments were supposed to hide the code from an old browser that did't understand a `<script>` tag. But all browsers born in the past 15 years know about `<script>`, so that's not an issue. So if you see such code somewhere you know the guide is really old and probably not worth looking into.
8679

8780
## Summary
8881

89-
<ul>
90-
<li>We can use a `<script>` tag without attributes to add JavaScript code to the page.</li>
91-
<li>A `<script>` tag blocks page rendering. Can be bad. Later we'll see how to evade that.</li>
92-
</ul>
82+
- We can use a `<script>` tag without attributes to add JavaScript code to the page.
83+
- A `<script>` tag blocks page rendering. Can be bad. Later we'll see how to evade that.
9384

1-js/2-first-steps/10-uibasic/1-simple-page/solution.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
JavaScript-code:
22

3-
```js
4-
//+ demo run
3+
```js demo run
54
let name = prompt("What is your name?", "");
65
alert( name );
76
```
@@ -16,7 +15,7 @@ The full page:
1615

1716
<script>
1817
'use strict';
19-
18+
2019
let name = prompt("What is your name?", "");
2120
alert( name );
2221
</script>
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# A simple page
1+
importance: 4
2+
3+
---
24

3-
[importance 4]
5+
# A simple page
46

57
Create a web-page which asks for a name and outputs it.
68

7-
[demo /]
9+
[demo]
810

0 commit comments

Comments
 (0)