[ES6] Getting started

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
Insert picture description here
2. string

  • Use backticks (the one above the Tab key) to write variables directly
  • Multi-line string
  • Farewell + stitching string
    Insert picture description here

3. Function extension

  • Arrow function
    Insert picture description here
  • 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
    Insert picture description here

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)
    Insert picture description here
    destructuring assignment
    function can also return multiple values

  • Array destructuring

  • Object deconstruction
    Insert picture description here
    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

Insert picture description here
I hope it will be helpful to everyone, and wish us all to be outstanding learning champions! !

Published 8 original articles · won 27 · views 1247

Guess you like

Origin blog.csdn.net/weixin_43764030/article/details/105544558