what I'm trying to accomplish is , a sub/child
class
of Array<T>
, that has my own custom methods , but am facing a problem here , I can't edit the items within the Array
...
lets see an example to clarify what I'm doing:
export class Collection<T> extends Array<T>
{
remove(key, value) {
this = this.filter(function (el) {
return el[key] !== value;
});
}
}
so I can have an Array
of User
let users:Collection<User> = [];
//add stuff etc ...
//then I can say
users.remove('name','Jhone Doe');
so it remove any items that has a key
name
and value
Jhone Doe
, but clearly I can't assign the this
instance , so how would I tackle that?