N
let object = {
'key1': 'value1',
'key2': 'value2',
'keyn': 'valuen',
};
console.log(object);
N
function Dog() {
this.name = "Bailey";
this.colour = "Golden";
this.breed = "Golden Retriever";
this.age = 8;
}
N
//initialized object
var object = {
property1: "a",
property2: "b",
}
//object initializer function
function object(property1, property2)
{
this.property1 = property1;
this.property2 = property2;
}
//initializing using the initializer function
var mouse = new object("ab", "cd");
N
class ObjectLayout {
constructor() {
this.firstName = "Larry"; //property
}
sayHi() { // Method
return `Hello from ${this.firstName}`;
}
}
const object = new ObjectLayout();
// object.firstName is Larry;
// object.sayHi() gives "Hello from Larry"