JavaScript code below.
class Test{
testMethod1() {
console.log('hello world');
}
testMethod2() {
this.testMethod1();
}
}
let t = new Test();
t.testMethod1();
t.testMethod2();
I already know that when calling a method from another method in the same class needs a this
pointer.
But why JavaScript need this?
Seems that cpp, java and othter object oriented langauge do not need this
.