Article Directory
1. What is ES6
New JavaScript syntax standard
- Officially released in June 2015
- Use babel syntax converter to support low-end browsers
- Popular libraries are basically built on ES6, React and vue are developed using ES6 new syntax by default
2. What's in ES6
1. Scope
let and const
let: the internal scope in the curly braces is valid
const: define unmodifiable variables
2. string
- Use backticks (the one above the Tab key) to write variables directly
- Multi-line string
- Farewell + stitching string
3. Function extension
- Arrow function
- Parameter default
const add = (num1,num2=1) =>{ //num2默认值为1
return num1+num2
}
console.log(add(3,4)) //输出7
console.log(add(3)) //输出4
- Expansion function
Extended object
Object extension
-
Object.keys, values, entries
Object.key
return value: a string array representing all enumerable properties of a given object -
Object method shorthand, calculating attributes
-
Spread operator (not ES6 standard, but also supported by babel)
destructuring assignment
function can also return multiple values -
Array destructuring
-
Object deconstruction
modularization
ES6 comes with a modularization mechanism, say goodbye to seajs and require.js -
Import, import {}
-
Export , Export default
-
Node does not support it yet, you need to use require to load files
I hope it will be helpful to everyone, and wish us all to be outstanding learning champions! !