Adding methods to es6 child class

11447
September 07, 2017, at 11:35 PM

I would like to make a new class that derives from Array that has its own methods in addition to the regular array methods.

export class ObjectCollection<T extends Iidentifier> extends Array<T> {
  constructor(collection: T[] = []) {
    super(...collection);
  }
  // used for getting instance from a collection of objects
  public getInstance(id: Id) {
    return this.find(item => item.Id.toString() === id.toString()) || new 
    Array<T>();
  }
}

I have also have child classes that inherit from that class.

export class TargetCategories extends ObjectCollection<TargetCategory> {
  constructor(categories: TargetCategory[] = []) {
    super(categories);
  }
  public getCategoryType(id: Iidentifier): string {
    return this[id].Category.length < 2 ? "dummy" : "saved";
  }
}

When I instantiate a TargetCategories object, I'm only able to use methods that are in array though. I'm not able to call things like getCategoryType and getInstance.

  • Free tv-shows 2019 are on https://www.putlockers.name/series/ without registration.
READ ALSO
Issue in Drupal Dashboard

Issue in Drupal Dashboard

I download a code of dashboard in codepen: https://codepenio/mr_alien/pen/pNRQxK, but i need this in drupal, so I make the respective changes but I have this issue(the site work but show this issue):

274
Add attribute to a html element from php if else condition

Add attribute to a html element from php if else condition

I have 2 database tableOne is for menu name and another is for child menu name

262
Remove duplicate values in a bidimensional array starting from index 0

Remove duplicate values in a bidimensional array starting from index 0

Which is the best way to remove duplicate values from bidimensional array? For example, my array looks like this:

225