Hi I am trying to run below program. I have one function hello
and I am calling it inside b
. It gives me an error
TypeError: Cannot read property 'hello' of undefined
class ChildClass {
// constructor
constructor(param, ...args) {
this.hello = function (a) {
console.log(a);
}
this.obj = {
a: {
b() {
this.hello(2)
}
}
}
}
}
Does anyone know what I am doing wrong here ?