es6语法小计

ES6

  • 箭头函数Arrow functions: this.setState({pressed: true})}
  • 块级作用域Block scoping: let greeting = 'hi';
  • 数组的扩展运算Call spread: Math.max(...array);
  • 类Classes: class C extends React.Component { render() { return ; } }
  • 常量Constants: const answer = 42;
  • 解构Destructuring: var {isActive, style} = this.props;
  • for...of: for (var num of [1, 2, 3]) {}
  • 模块Modules: import React, { Component } from 'react';
  • 动态属性键Computed Properties: var key = 'abc'; var obj = {[key]: 10}; console.log(obj); // { abc: 10 }
  • 对象方法的简写Object Consise Method: var obj = { method() { return 10; } };
  • 对象属性的简写Object Short Notation: var name = 'vjeux'; var obj = { name };
  • 参数的扩展运算Rest Params: function(type, ...args) { }
  • 字符串模板Template Literals: var who = 'world'; var str =Hello ${who};

引用

javascript-environment
modules

你可能感兴趣的:(es6语法小计)