Make base class which operates on a child class

40 Views Asked by At

I know I'm conceptually wrong somewhere here, but how would you arrange this type of situation? I think my confusion would be clear from the code below:

  class Base {

    constructor() {
        this._defineProperties( this.properties );
    }

   _defineProperties(properties) {
       properties.forEach((value, key) => {
           Object.defineProperties(this, key, {
             value: value,
             enumerable: true
           })
        });
   }
}


class Child extends Base {

    properties: {
      'title': '',
      'text': ''
    }
}


const obj = new Child();
child.title
child.text
0

There are 0 best solutions below