js creating an object code example
Example 1: creating an object javascript
let obj = {
// fields
name:"value",
num: 123,
//methods
foo: function(){}
}
Example 2: javascript object
let names = {
name1: 'What ever you want to put'
}
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...
Example 4: how to create a object in javascript
var about = {
name:"lanitoman",
age:1023,
isHeProgrammer:true
}