Beace Lee

Beace Blog

Written by Beace Lee who lives and works in China building useful things. You should follow him on Twitter

ECMAScript 2015 Features-c10-subclassed

February 21, 2017

ECMAScript 2015 Features

Subclassed

在ES6中,Array,Date,DOM元素都可以被继承子类化。

class MyArray extends Array {
  constructor(...args) {
    super(...args);
  }
}

var myarr = new MyArray();
myarr[0] = 1;
console.log(myarr, myarr.length); //MyArray [ 1 ] 1
}