how to create object of objects in javascript code example
Example 1: Build JavaScript Objects
var myDog = {
name: "gozi",
legs: 4,
tails: 1,
friends: ["Ted", "Fred"]
};
Example 2: objects javascript
function Dog() {
this.name = "Bailey";
this.colour = "Golden";
this.breed = "Golden Retriever";
this.age = 8;
}
Example 3: 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...