DEV Community

Keerthiga P
Keerthiga P

Posted on

Objects in Javascript

Object
An object represents a real-world entity and contains properties data and methods (functions).
An object is a collection of key–value pairs used to store related data and functionality together.

Example:
let obj={
name:"keerthi",
age:23,
color:"violet"
};
console.log(obj)

Add new attributes
let Object = {
name: "Keerthi",
age: "23",
qualification: "msc"
};
Object.color="voilet";
Object["number"]="7";
console.log(Object);

remove attributes
let Object = {
name: "Keerthi",
age: "23",
qualification: "msc"
};
delete Object.age;
console.log(Object);

Update attributes
let obj={
name: "keerthi",
age:23
}
obj.age="24";
console.log(obj);

Top comments (0)