I am trying to make a custom Array class by extending the native Array, but I can't figure out how to empty the elements, here's my try.
class MyArray extends Array {
// for simplicity I just included the bit of code that fails.
reset () {
this = []; // fails of course
}
}
const myarray = new MyArray();
myarray.push(1);
myarray.reset(); // fails because it tries to rewrite `this`
What am I doing wrong ?