define an object javascript code example
Example 1: js object
let car = {
name: "BMW",
colour: "black",
year: "2020",
owner: {
names = ["Andy" , "Steve" , "Tony" ]
}
};
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.");
Example 3: javascript object
const object = {
something: "something";
}
Example 4: how to create a object in javascript
var a = {
name: "aakash",
age:30
}
Example 5: objects in javascript
let name = {
name1: 'mark'
}