ES6
-
箭頭函數(shù)Arrow functions:
<C onPress={() => this.setState({pressed: true})}
-
塊級作用域Block scoping:
let greeting = 'hi';
-
數(shù)組的擴展運算Call spread:
Math.max(...array);
-
類Classes:
class C extends React.Component { render() { return <View />; } }
-
常量Constants:
const answer = 42;
-
解構(gòu)Destructuring:
var {isActive, style} = this.props;
-
for...of:
for (var num of [1, 2, 3]) {}
-
模塊Modules:
import React, { Component } from 'react';
-
動態(tài)屬性鍵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 };
-
參數(shù)的擴展運算Rest Params:
function(type, ...args) { }
-
字符串模板Template Literals:
var who = 'world'; var str =
Hello ${who};