JS unnamed class and its unnamed extended class

107 Views Asked by At

Operation class creates an array like this, which has no class name before the array.

[operInputQuery[0].value, operInputQuery[1].value, operInputQuery[2].value]

'Table' class is purposed to be an unnamed class inheriting Operation's constructors.

It inherits properly, however, it creates the array with the unnecessary tag extends like this.

extends[operInputQuery[0].value, operInputQuery[1].value, operInputQuery[2].value, operInputQuery[3].value]

Yes, I do not want to create the array with 'extends' thing.

How can I make an unnamed extended class?

let Operation = class { //unamed class
  constructor(a, b, c) {
    this.a = operInputQuery[0].value;
    this.b = operInputQuery[1].value;
    this.c = operInputQuery[2].value;
  }
}

let Table = class extends Operation { //purposed to write an unnmaed extended class
  constructor(a, b, c, d){
    super(a, b, c);
    this.a;
    this.b;
    this.c;
    this.d = operInputQuery[3].value;
    }
};

1

There are 1 best solutions below

1
sonEtLumiere On

operInputQuery is missing but i guess is an array of objects with value property, try this:

let operInputQuery = [{value: 1}, {value: 2}, {value: 3}, {value: 4}];

let Table = class { 
  constructor(a, b, c, d){
    this.a = a;
    this.b = b;
    this.c = c;
    this.d = d;
    }
};

let table = new Table(operInputQuery[0].value, operInputQuery[1].value, operInputQuery[2].value, operInputQuery[3].value);
console.log(table);