ES6 Summary Supplement

Source: Internet
Author: User

A, let, Var, and const

1. Let there is no variable promotion

2. Let variables cannot be declared repeatedly var variables can be declared repeatedly (the variables declared later overwrite the previously declared variables, but do not do so at the end)

3, if the block exists let and const commands, this block of these commands declared variables, from the beginning to form a closed scope, even though the global variable declared a variable of the same name, the effect of the same

4. Block-level scope {} Especially if and for

5, for a compound type of variable, the const command only guarantees that the variable name points to the same address, does not guarantee that the address of the data is not changed

6. ES5 There are only two ways to declare variables: thevar command and the function command. ES6 added: let命令、 const commands, commands, import and class commands

Second, the deconstruction assigns the value

1, as long as a certain data structure has iterator interface, can be used in the form of an array of deconstruction assignment

2, specify the default value, the same way as the function parameter specifies the default value

3, if an array member is not strictly equal undefined to, the default value will not be effective//only undefined will trigger the default value

3. Object attributes have no order, variables must have the same name as property

4, the elements of the array are arranged in order, the value of the variable is determined by its position

5. The internal mechanism of the object's deconstruction assignment is to find the property of the same name before assigning it to the corresponding variable. The actual assignment is the latter, instead of the former object specifying that the default value is still specified for the latter//{test:test=default}={}

var {name,age}={age: "+", Name: "Soul"};    // {name:name,age:age}={age: "+", Name: "Soul"}; Console.log (name);    // SoulConsole.log (age);    //  + var {name:varname,age:varage}={age: "+", Name: "Soul"};console.log (varName);     // SoulConsole.log (varage);    //  +

Three, string

1. Template string: ' ... String ... ${//js code ...} ... String ... '//If you need to use "" in a string, all spaces and indents will remain in the output

2, Label Template: The return value is the function of the return value of the function's first parameter is the template original string using ${} as the delimiter formed after the array, including the space the second parameter is the result of the first ${} The third argument is the result of the second ${} ...

  

3,String.raw method: Often used as a template string processing function, used to handle the ' \ '

  

Four, the regular expression

1, regexpobject.exec (string);//Returns an array of arr=[pattern,index:num,input:str]; The regular matching pattern, the index of the matching result, the original string pattern =arr[0],index and input need to use the. operator

  

2, the string of the regular method:

    • Strobj.match (REGEXP); Returns an array that holds the matching results
    • Strobj.replace (Regexp,replacer); Returns the new string after replacement
    • Strobj.search (REGEXP); Returns the first match to the starting position of the match failure then returns-1
    • Strobj.split (Separator,limit); An array of strings. The string in the returned array does not include the separator itself. The limit represents the maximum length of the array.

  

Five, numeric (number object and math object)

1, Math.trunc (num);//The number of decimal parts used to remove NUM returns the integral part

2, Math.floor (num); Used to rounding num down

3, Math.ceil (num); Used to rounding num up

Implemented as follows
function (x) { return x < 0? Math.ceil (x): Math.floor (x);};

4, MATH.CBRT ();//used to calculate the cube root of a number

5, Math.pow (x, y); Returns the Y-order of X

6, Math.Round (x); Rounds x to the nearest integer

Six, array

Seven, function

1, the arrow function does not own this but refers to the outer environment of this

Viii. Expansion of objects

1, Object. Getownpropertydescriptor(obj, attribute)//Property Description Object

2. Shorthand for object properties and methods

Nine, Symbol

1, Symbol.for (symbolname); First detect if the symbolname exists and if it does not exist, create a new symbol

X. Proxy and reflect

Xi. binary Arrays

12. Set and map structure

1. Nan equals itself in the set structure

2. Extension ... Set and map structures can be converted to arrays

13, Iterator

1. The [Symbol.iterator] Property of the object

2. Next method is mandatory, return method and throw method deployment is optional

3, general use of the generator function [Symbol.iterator] properties of the deployment

var person={};p erson[symbol.iterator]=function* () {    1;     2;     // ...};

14, Generator

XV, Promise

1. Synchronous notation of asynchronous operation

16. Class

17. Module

ES6 Summary Supplement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.