Template string
Action: easier to reconstruct the string
-
Template string must contain ``
-
Changing portion comprising using $ {xxx}
Shorthand object
-
Property of the same name can be omitted
-
Arrow function
Features arrow function
-
Arrow function does not own this, when this is not the function of the arrow called the decision, but when defined in this object is its
-
Extended understand:
-
this function of the arrow to see if there is a function of the outer layer
-
If there is, the outer layer of this function is a function of this internal arrow
-
If not, then this is the window
-
Where the shape parameter
-
When there is no parameter
let fun1 = () => console.log(a);
fun1(); -
Only one parameter of time
let fun2 = a => console.log(a);
fun2('aaa');
3. two or more of the parameter when two () can not be omitted
let fun3 = (x,y) => console.log(a);
fun3(35,52);
Function body case
-
When only one body of the function or the expression {statement} may be omitted ------> Results but will automatically executed statement or expression
-
Function body case more than one statement or expression can not be omitted {}
Three operators
1.rest (variable) parameters
To replace arguments, but flexible than arguments, only part of the last parameter Parameter
2. Extended operator
Object promise
1. Understanding
-
promise Object: represents a time in the future will happen (usually an asynchronous operation)
-
With the promise objects, asynchronous operation may be expressed in a synchronized process, avoiding deeply nested callback function (commonly known as callback function)
-
Promise ES6 is a constructor to generate promise Examples
2. The basic steps promise object
# Create Object promise
the let promise = new new Promise (( resolove, Reject) => { // Initialization state Pending // perform asynchronous operation if ( asynchronous operation success) { Resolve ( value); // modify the status promise is fullfilled } {the else Reject ( errMsg An); // status is modified promise Rejected } }) # promise of the then call () promise. the then ( function ( Result => Console. log ( Result), erroring => Alert ( erroring) )
Three states 3.promsie object
-
pending: initialization state
-
fullfilled: success status
-
rejected: the failed state
4. Applications
-
Use premise ultra-try
-
The encapsulation process using the promise ajax request
let requset = new XMLHttpRequset();
requset.onreadystatechange = function(){
}
request.responseType = 'json';
requset.open('GET',url);
requset.send();
Symbol
ES6 new primitive data types
Features:
-
Symbol value of the property value is only to resolve naming conflicts
-
Symbol value can not be calculated with other data, including strings with strings spell
-
3.for in, for of traversal attribute not traverse symbol
use:
-
Call the Symbol function to get the symbol value
-
Pass parameters to identify
-
Built-in Symbol value
-
In addition to defining Symbol values other than their own use, ES6 also provides 11 built-in Symbol value, directed to a method of using internal language
Symbol.iterator
-
Symbol.iterator properties of the object point to the default method is to traverse the object
-
iterator Interface
The iterator interfaces deployed on the specified data type, can be used for of loop iterates
Arrays, strings, arguments, set container, map container