using functiuons to crete objects code example

Example 1: js create object with properties

function Car(make, model, year) {
  this.make = make;
  this.model = model;
  this.year = year;
}

Example 2: js create new object

let bike = {   name: 'SuperSport',    maker:'Ducati',    start: function() {       console.log('Starting the engine...');   }};bike.start();   //Output: Starting the engine.../* Adding method stop() later to the object */bike.stop = function() {    console.log('Applying Brake...');  }bike.stop();    //Output: Applying Brake...

Tags:

Java Example