I am studying the oops concepts in jquery But I am facing some problem . First I learn how to create class .
function Car(speed) {
alert("Class CAR Instantiated");
this.speed = speed;
}
Car is class speed is parameter , Then I create object of that class like that
var car1 = new Car(40);
But The problem is that there is keyword prototype ,I think it is used to create function in class ?
Car.prototype.speed= 'Car Speed';
Car.prototype.setSpeed = function(speed) {
this.speed = speed;
alert("Car speed changed");
}
But when I call setSpeed function it is called .But when I called speed function (mean alert Car Speed). It is not called
Here is my fiddle ..