Understanding es6

1.ECMA standard, JS achieve
2.ES6 (ES2015) - IE10 +, Chrome, FireFox, movable end, NodeJS
3. compilation, conversion:
1, the line-conversion browser.js === babel as specified script type = " text / Babel "
2, compiled ahead (recommended)
4.ES6 new features:
1. variable
2. function
3 array
4. string
5. object-oriented
6.Promise
7.generator
8. The modular
5.ES6 variables:
var questions:
1. can redeclaration
2 can not modify the restriction
3. there is no block-level scope {} if () {} block variables defined inside out not to visit
the let: not redeclaration, variable - may be modified, block level scope
const: statement can not be repeated, constant - can not be modified, the block-level scope
6. function - function arrow
before:
function name () {

}
current:
() => {

}

1. If only one parameter () can be omitted
2. If only one return, {} may be omitted
Array.sort ()
7. The function parameters
1. Parameter extended / expanded array (...)
2. default parameters

Extended parameters:
1. Collect the remaining parameters
function Show (A, B, ... args) {}
* Rest the Parameter MUST BE Last
2. Expand array
* effects after deployment, directly with the contents of the array as written here
let = ARR [. 1, 2,. 3];
... ARR <==>. 1, 2,. 3
--------------------------- -----------------------
default parameters:
$ ( '# DIV1') Animate. ({width: '200px'});
$ ( '# DIV1 ') .animate ({width:' 200px '}, 1000);
8. the destructuring assignment:
the left and right sides of the structure must be consistent 1.
2 must be the right thing
3 and assignment statement can not be separated (in a word must be completed)

the let [A, B, C] = [12 is,. 5,. 8];
the let {A, B, C} = {A: 12 is, B:. 5, C:. 8};
9. The array
1.map a map one
[12, 58, 99, 86]
[not pass, fail, pass, fail]
2.reduce summary out a bunch
3.filter filter
4.forEach loop (iteration)
10. string
1. more than two new method
StartWith
endwith the
2. template string
a string which directly can stuff into something $ {}.
B can be wrapped.
Object-oriented 11.ES6 of:
1.class keywords, and constructed a separate class
2. class method which directly added
12. Inheritance:
super-- == parent superclass
13. The object-oriented application --React
React:
1. assembly of --class
2.JSX
JSX == == Babel browser.js
JSX the JS extension version
14.json:
json objects:
json standard wording:
a can only use double quotes.
All key must be wrapped with quotes b.
json abbreviations are used:
the same name: key value and the like may be only one
method: omitted: function
15.promise:
- elimination of asynchronous operation: synchronous same way, to write asynchronous code;

Asynchronous: nothing relationship between the operation, multiple simultaneous operations, but the code more complicated
: Simultaneously can only do one thing, but the code is simple

Promise.all ([
$ .ajax (), $ .ajax ()
.]) The then (function () {
// success
}, function () {
// failure
});

16.generator-- generators
ordinary function - all the way in the end
generator function - can stop the middle, kick kick go one step further,

yield
- parameter passing
- return

 

 

 

 

 

 

 

 


 

Guess you like

Origin www.cnblogs.com/caicai521/p/11262075.html