I try to create a custom Array class by extending the generic Array one. On this class I want to create a custom find / filter. When I call the custom find
it works well, but when I call the filter
I get a problem with the iterator.
There is my code
class MyClass extends Array {
constructor(inArray){
super();
this.push(...inArray);
}
myFind(callback) {
return this.find(callback);
}
myFilter(callback) {
return this.filter(callback);
}
}
//Works
console.log(new MyClass(["a","b"]).myFind(item => item === "a"));
//Do not work
console.log(new MyClass(["a","b"]).myFilter(item => item === "a"));