
ecmascript 6(以下簡稱 es6)總共新增了20多項重大的語言特性。各種浏覽器和 node.js 都積極支援,但還有不少功能沒實作。
(1)指令行環境
(2)node環境
将 es-checker 安裝在項目的根目錄。
就可以在腳本中引用 es-checker 了。
supports 對象的屬性清單,請見後文。
(3)浏覽器環境
将 es-checker.js 插入頁面。
然後在腳本中使用 supports 對象,決定哪些功能可以使用。
letconst: let 和 const 指令
defaultparameter: 函數的預設參數
spreadrest: 擴充(...)運算符
destructuring: 解構指派
parameterdestructuring: 函數參數的解構
templatestring: 模闆字元串
forof: for...of循環
arrow: 箭頭函數
generator: generator函數
concisemethodproperty: 對象屬性的簡潔表示法
computedproperty: 對象屬性名使用表達式
moduleexport: 子產品的export指令
moduleimport: 模闆的import指令
numericliteral: 數值的八進制和二進制表示法
oldoctalliteral: 八進制的字首零表示法
symbol: symbol類型
unicodeescape: unicode字元的大括号表示法
unicodeidentifier: unicode字元是否可用作辨別名
unicoderegexp: 正規表達式的u修飾符
stickyregexp: 正規表達式的y修飾符
class: 類(class)
lettdz: let指令的暫時性死區
constredef: 不允許再次用const聲明同一變量
objectproto: 對象的proto屬性
objectsuper: 對象方法是否可以使用super
extendnatives: 原生類型的擴充
tco: 尾調用優化
symbolimplicitcoercion: symbol值不能用于運算
functionnameinference: 匿名函數的name屬性推斷函數名
objectstatics: object的靜态方法
arraystatics: 數組的靜态方法
arraymethods: 數組的執行個體方法
typedarrays: 類型化數組
typedarraystatics: 類型化數組的靜态方法
typedarraymethods: 類型化數組的執行個體方法
stringmethods: 字元串的執行個體方法
numberstatics: number對象的靜态方法
mathstatics: math對象的靜态方法
collections: map, set, weakmap, weakset
proxy: proxy對象
promise: promise對象
(完)