As the title said, I have two class like below:
class A {
constructor() {
this.a = 1
this.b = 2
}
}
Class B extends A {
constructor() {
super()
this.c = 3
}
}
Now, I instance class B
const b1 = new B()
Can I use some method to get the { a:1, b:2 } from b1. Because I need to post some data through API. But my model is something like class B. but the interface of the API is like class A. So I just want to get the parent object from the child object. Thanks in advance.
Bobject is anAobject too, and can be used whereAobjects are expected.console.log(b1 instanceof B, b1 instanceof A);.