I try to access the properties of my "Foo" class. My code looks like this:
class Foo {
constructor(myname) {
this.myname = myname;
}
}
Foo.prototype.get = {
name() {
return this.myname;
}
};
const TestClass = new Foo('Steven');
TestClass.get.name(); // undefined
Its clear that in TestClass.get.name
the myname
property does not exists because the this
context is TestClass.get
No I am looking for a recommended way to access myname
. Smth like: Parent.myname.