What is this keyword in JavaScript?

Forums JavaScriptWhat is this keyword in JavaScript?
Staff asked 2 years ago

Answers (1)

Add Answer
Nayan Raval Marked As Accepted
Staff answered 2 years ago

The this keyword relates to the current object and is a reference variable. As an illustration:

var address=    
{    
company:"CodeHubs",    
city:"Noida",    
state:"UP",    
fullAddress:function()    
{    
return this.company+" "+this.city+" "+this.state;    
}    
};    
var fetch=address.fullAddress();    
document.writeln(fetch);

 

Subscribe

Select Categories