As much as I try, I have read and tried many exercises and examples to understand the keyword "this" but so far I cannot understand how it works. The fact that "represents" objects confuses me too much. On my way to continue learning this language, I have hope that someone here can explain me, in his best attempt, to understand how it works.
I've also been trying to understand how this example works because it might help me to learn the subject:
Example from:
JavaScript Bible
Seventh Edition
Part III - JavaScript Core Language Reference
Chapter 23 - "Function Objects and Custom Objects"
Page: 446
I appreciate in advanced any help in teaching me this "this".
I've also been trying to understand how this example works because it might help me to learn the subject:
Code:
//function to be invoked as a method from a "car" object
function showCar() {
alert(this.make + " : " + this.color)
}
//"car" object constructor function
function Car(make,color) {
this.make=make;
this.color=color;
this.show=showCar;
//create instance of a "car" object
var myCar=new Car("Ford","blue");
myCar.show();
}
Example from:
JavaScript Bible
Seventh Edition
Part III - JavaScript Core Language Reference
Chapter 23 - "Function Objects and Custom Objects"
Page: 446
I appreciate in advanced any help in teaching me this "this".