I have to instantiate the class obj1
, which returns a dict, and pass this object into another instantiation of a class like this:
const obj1 = new Class1()
const obj2 = new Class2({ obj1, id: 8 })
This works fine, but the problem comes when i wrap this process into a class.
Class X () {
constructor(newId) {
this.obj1 = new Class1()
this.obj2 = new Class2({this.obj1, id: newId})
}
}
This time it throws Referenceerror: obj1 is not defined
when i instantiate the class.
I think it’s because node tries to read this.obj1
as this:obj1
since we are in the context of a dict.
This might seem stupid but I’m stuck.
Any help ?