I have a function inside an object inside a Class.
The object of the class is initialized and I want to call the function, but the function need a variable defined on the constructor of the Class.
class someClass {
constructor() {
this.foo = "bar";
this.print = {
variable: function() {
console.log(this.foo);
}
};
}
}
// And I call it from the global scope
var someObject = new someClass();
someObject.print.variable();
It will print
undefined
I know is a different scope and maybe I can't access to it.
The objective of this is to have some order with my functions.
I want to access to my function like someObject.print.variable();