How to extends an object with class in ES6?

I'm not quite sure I understand your need, but it seems like somthing simple like this should suit your needs:

class SomeClass {
  constructor(obj) {
    Object.assign(this, obj);
    // some codes here
  }
  // some methods here..
}

That way

var obj = new SomeClass({a:1, b:2, c:3, d:4, e:5, f:6});

works just fine.


Think you probably want something like:

class SomeClass {
  constructor(o) {
    Object.assign(this, o);   
  }  
}

console.log(new SomeClass({a:1}))
console.log(new SomeClass({a:1, b:2, c:3, d:4, e:5}))