construct object javascript code example
Example 1: creating an object javascript
let obj = {
name:"value",
num: 123,
foo: function(){}
}
Example 2: js constructor object
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}
var car1 = new Car('Eagle', 'Talon TSi', 1993);
console.log(car1.make);
Example 3: javascript construct new object
person = new Object();
Example 4: js create new object
let bike = { name: 'SuperSport', maker:'Ducati', start: function() { console.log('Starting the engine...'); }};bike.start();