I'm using Babel for extend my class with the built-in native Array
class NewArray extends Array {
first() {
return this[0];
}
}
var a = new NewArray(1, 2, 3);
console.log(a.length); // 3
console.log(a); // [ 1, 2, 3 ]
console.log(a.first()); // trigger error
In a.first(), I'm getting this error:
console.log(a.first());
^
TypeError: a.first is not a function
Should I do something more to extend a built-in native?
Thanks!