+ 1
Can anyone explain in details the use of "this" keyword to me?
I have just been going through getters and setters and I encountered the this keyword and I can't understand how it works. I am weak in Java and the OOP concept confuses me a lot here.
1 Odpowiedź
0
the "this" keyword is used to make reference to the current object.
it's primarily used in Class creations.
Here's a quickie on its usage
==================
function intro(){
var name=this.name;
var city=this.city;
console.log("Hello, am "+name)
console.log("Am from "+city)
}
var Yahiko={
name:"Yahiko",
city:"Konoha"
}
var Dlite={
name:"Dlite",
city:"Ohio"
}
intro.call(Dlite)
into.call(Yahiko)
Result
=======
Hello, am Dlite
Am from Ohio
Hello, am Yahiko
Am from Konoha
Good Luck