create object in html javascript code example
Example 1: creating an object javascript
let obj = {
name:"value",
num: 123,
foo: function(){}
}
Example 2: objects javascript
function Dog() {
this.name = "Bailey";
this.colour = "Golden";
this.breed = "Golden Retriever";
this.age = 8;
}
Example 3: javascript construct new object
person = new Object();
Example 4: make an object javascript
class ObjectLayout {
constructor() {
this.firstName = "Larry";
}
sayHi() {
return `Hello from ${this.firstName}`;
}
}
const object = new ObjectLayout();