object methods javascripts code example
Example 1: objects in javascript
let object = {
'key1': 'value1',
'key2': 'value2',
'keyn': 'valuen',
};
console.log(object);
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...