class Hello{
constructor(member) {
this.member = member;
this.name_function_map = {"print_member" : this.print_member};
}
print_member(){
console.log(this.member);
}
}
let h = new Hello(2);
h.print_member();
//=> works as expected
h.name_function_map["print_member"]();
//=> why is it h. member undefined
the output is:
2
undefined
can someone please enlighten me, why is calling the member function of Hello through a reference stored in a map any different than calling it directly?
And how may i work around that.