how to declare an object javascript code example
Example 1: objects in javascript
let car = {
engineNumber: 1234
brand: 'BMW',
break: function (){}
}
Example 2: how to create object js
function person(fname, lname, age, eyecolor){
this.firstname = fname;
this.lastname = lname;
this.age = age;
this.eyecolor = eyecolor;
}
myFather = new person("John", "Doe", 50, "blue");
document.write(myFather.firstname + " is " + myFather.age + " years old.");