Reputation: 582
I have the following code in es6 and I want to convert it to es5.
class PowerArray extends Array {
isEmpty() {
return this.length === 0;
}
}
let arr = new PowerArray(1, 2, 5, 10, 50);
console.log(arr.isEmpty()); // -> empty
console.log(arr.filter(item => item >= 10)); // -> 10, 50
I tried using Array.prototype.filter.call(context, callback), but I can't figure out what to pass in the first argument. Is it even possible to accomplish this?
I know I can use Babel, but this question is for learning purposes.
Upvotes: 0
Views: 49