Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript classes

class Car {
  constructor(name, year) {
    this.name = name;
    this.year = year;
  }

  carDetails() {
    console.log("Car name: " + this.name, "
Car year: "+ this.year);
  }

  drive() {
    console.log("Driving!")
  }

}

let car = new Car("Audi", 2019);
car.carDetails();
car.drive();
 
PREVIOUS NEXT
Tagged: #javascript #classes
ADD COMMENT
Topic
Name
8+2 =