ES6 inputs class
, extends
, constructor
and so on, which simplifies inheritance based on prototypes. I want to create an object built through a class constructor on another object. What is the cleanest way to do this in this new syntax way of constructing objects?
class A {
constructor(json) {
let base = JSON.parse(json);
this.prototype = base;
}
}
I would use extends
, but since the object is passed, there is no other class definition here
source
share