Property in JavaScript

Properties are the variable that are member of an object and can define the state of any instance of Class. Property of a class can be accessed within the class using this keyword.

JavaScript
function Car(speed) {
    this.speed = speed;
}

var car1 = new Car(40);
var car2 = new Car(60);

alert("Car1 Speed: " + car1.speed);
alert("Car2 Speed: " + car2.speed);

results matching ""

    No results matching ""