class Test {
X = 'X';
someFunc = () => {
console.log('someFunc is called');
//someFunc2(); // undefined
this.someFunc2(); //works
}
someFunc2() {
console.log('someFunc2 is called');
}
}
Z = new Test();
console.log(Z.hasOwnProperty('X')); // true
console.log(Z.hasOwnProperty('someFunc')); // true
console.log(Z.hasOwnProperty('someFunc2')); // false
Z.someFunc();
I'm trying to understand when i should use this
keyword, as far as i know it's used when trying referring/using some object property, but in the code above i tried to test is someFunc2
is property of the object and it returned false but still can called through this.someFunc2();
. So does that mean this
keyword not for accessing object property?