this Keyword in JavaScript - JavaScript Tutorial 79

Veröffentlicht am: 21 März 2018
auf dem Kanal: ChidresTechTutorials
3,753
86

Notes for You:: this Keyword in JavaScript - JavaScript Tutorial 79
is a special keyword present inside every constructor function & methods.
is a reference variable, which always points to the object with which we are currently working.
is used to access members (i.e. attributes & behaviors) of the currently working object.

Actual Code:

function Rectangle(width,height)
{
this.width = width;
this.height = height;
this.getArea=function()
{
return this.width * this.height;
}
}
var rect1 = new Rectangle(5,5);
document.write(rect1.getArea());
document.write("<br/>");

var rect2 = new Rectangle(6,6);
document.write(rect2.getArea());
document.write("<br/>");



Behind the scene code:

function Rectangle(width,height,this)
{
this.width = width;
this.height = height;
this.getArea=function(this)
{
return this.width * this.height;
}
return this;
}
var rect1 = new Rectangle(5,5,#1);
document.write(rect1.getArea(rect1));
document.write("<br/>");

var rect2 = new Rectangle(6,6,#2);
document.write(rect2.getArea(rect2));
document.write("<br/>");

Notes:
replace < with less-than symbol.
replace > with greater-than symbol.



=========================================

Follow the link for next video:
JavaScript Tutorial 80 - Difference between prototype and proto_ in JavaScript
   • __proto__ vs prototype in JavaScript ...  

Follow the link for previous video:
JavaScript Tutorial 78 - How to create Objects using Constructor function in JavaScript
   • How to create Objects using JavaScrip...  

=========================================

JavaScript Tutorials Playlist:-
   • JavaScript Tutorials  

=========================================
Watch My Other Useful Tutorials:-

jQuery Tutorials Playlist:-
   • jQuery Tutorials  

jQuery UI Tutorials Playlist:-
   • jQuery UI Tutorials  

Bootstrap Tutorials Playlist:-
   • Bootstrap4 Tutorials  

=========================================

► Subscribe to our YouTube channel:
   / chidrestechtutorials  

► Visit our Website:
https://www.chidrestechtutorials.com

=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial


Auf dieser Seite können Sie das Online-Video this Keyword in JavaScript - JavaScript Tutorial 79 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer ChidresTechTutorials 21 März 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 3,753 Mal angesehen und es wurde von 86 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!