1: New data type
- ES5 data types: number, string, boolean, null, undefined, object
- ES6 data types: bigInt, symbol
Two: new data structure
ES5 has data structures: Array, Object
ES6 new data structure: Set, Map
Set and Map are the perfection of Array and Object respectively.
- set: The extension of the array, set is equivalent to an array without duplicates. The constructor of Set can accept an array.
- Map: The key of a traditional Object can only be a string, and a Map can be understood as an object whose key can be a variable.
Three: Array
Array.from: Convert class arrays to data, such as set, map, argument, dom objects
Array.of: Convert a set of arrays to an array
The new from method of Array can be used together with the new Set data type of es5 to achieve the function of filtering the array as follows
Array.from(new Set([1,2,1,2])); // 返回[1,2]
Four: Modularization
1. Export: default/named export
There can only be one default export export default in a module, but there can be any named export (0, 1, multiple). For example, A.js can be exported in the following two ways
- export default 42
- export const A=42
2. Introduction
If the module is exported by default, curly braces are not used when importing; if it is a named export, curly braces are required when importing.
- import someting from "./A" // refer to the default exported module, the name of the import module is arbitrary
- import {A} from "./A" // To import a named and exported module, you need to add {}, and only the name of the import and export must be consistent