[Solved] Javascript Object to ES6 Classes

[ad_1]

Simply use the class statement to declare your class, then add its properties in the constructor and its (static) methods in the class’ body.

class Start {
  constructor() {
    this.config = {
      a: 1
    };
    
    this.core = {
      engine_part1: () => (console.log('engine_part1')),
      engine_part2: () => (console.log('engine_part2')),
    }
  }
  
  init() {
    console.log('init');
  }
}

const start = new Start;

console.log(start.config);

start.core.engine_part1();
start.init();

3

[ad_2]

solved Javascript Object to ES6 Classes