Merge branch 'en' of https://github.com/iliakan/javascript-tutorial into en
This commit is contained in:
commit
5191617c53
7 changed files with 11 additions and 11 deletions
|
@ -20,7 +20,7 @@ If you haven't considered selecting an IDE, look at the following variants:
|
|||
- [Komodo IDE](http://www.activestate.com/komodo-ide) and it's lightweight free version [Komodo Edit](http://www.activestate.com/komodo-edit).
|
||||
- [Netbeans](http://netbeans.org/).
|
||||
|
||||
All of them with the exception of Visual Studio are cross-platform.
|
||||
All of them with the exception of Visual Studio are cross-platform. Visual Studio is now available for Mac and for Windows (https://www.visualstudio.com/vs/visual-studio-mac/)
|
||||
|
||||
Most 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.
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@ So it's quite common for an engine to implement only the part of the standard.
|
|||
|
||||
A good page to see the current state of support for language features is <https://kangax.github.io/compat-table/es6/> (it's big, we have a lot to study yet).
|
||||
|
||||
## Babel.JS
|
||||
## Babel
|
||||
|
||||
When we use modern features of the language, some engines may fail to support such code. Just as said, not all features are implemented everywhere.
|
||||
|
||||
Here Babel.JS comes to the rescue.
|
||||
Here Babel comes to the rescue.
|
||||
|
||||
[Babel.JS](https://babeljs.io) is a [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler). It rewrites modern JavaScript code into the previous standard.
|
||||
[Babel](https://babeljs.io) is a [transpiler](https://en.wikipedia.org/wiki/Source-to-source_compiler). It rewrites modern JavaScript code into the previous standard.
|
||||
|
||||
Actually, there are two parts in Babel:
|
||||
|
||||
|
@ -33,7 +33,7 @@ Actually, there are two parts in Babel:
|
|||
|
||||
So, we need to setup the transpiler and add the polyfill for old engines to support modern features.
|
||||
|
||||
If we orient towards modern engines and do not use features except those supported everywhere, then we don't need to use Babel.JS.
|
||||
If we orient towards modern engines and do not use features except those supported everywhere, then we don't need to use Babel.
|
||||
|
||||
## Examples in the tutorial
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ function showArgs() {
|
|||
*/!*
|
||||
}
|
||||
|
||||
showList("John", "Pete", "Alice"); // John - Pete - Alice
|
||||
showArgs("John", "Pete", "Alice"); // John - Pete - Alice
|
||||
```
|
||||
|
||||
Because `join` resides in `Array.prototype`, we can call it from there directly and rewrite it as:
|
||||
|
|
|
@ -47,7 +47,7 @@ function User(name, birthday) {
|
|||
*!*
|
||||
// only visible from other methods inside User
|
||||
function calcAge() {
|
||||
new Date().getFullYear() - birthday.getFullYear();
|
||||
return new Date().getFullYear() - birthday.getFullYear();
|
||||
}
|
||||
*/!*
|
||||
|
||||
|
@ -76,7 +76,7 @@ Like this:
|
|||
function User(name, birthday) {
|
||||
// only visible from other methods inside User
|
||||
function calcAge() {
|
||||
new Date().getFullYear() - birthday.getFullYear();
|
||||
return new Date().getFullYear() - birthday.getFullYear();
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -294,7 +294,7 @@ class Article {
|
|||
*/!*
|
||||
}
|
||||
|
||||
let article = article.createTodays();
|
||||
let article = Article.createTodays();
|
||||
|
||||
alert( articles.title ); // Todays digest
|
||||
```
|
||||
|
|
|
@ -125,7 +125,7 @@ class Rabbit extends Animal {
|
|||
*!*
|
||||
stop() {
|
||||
super.stop(); // call parent stop
|
||||
hide(); // and then hide
|
||||
this.hide(); // and then hide
|
||||
}
|
||||
*/!*
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ The event handling process:
|
|||
Each handler can access `event` object properties:
|
||||
|
||||
- `event.target` -- the deepest element that originated the event.
|
||||
- `event.currentTarget` (=`this`) -- the current element the handles the event (the one that has the handler on it)
|
||||
- `event.currentTarget` (=`this`) -- the current element that handles the event (the one that has the handler on it)
|
||||
- `event.eventPhase` -- the current phase (capturing=1, bubbling=3).
|
||||
|
||||
Any event handler can stop the event by calling `event.stopPropagation()`, but that's not recommended, because we can't really be sure we won't need it above, maybe for completely different things.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue