Object is used to store data in key-value pairs and are used in almost every application, in this blog we are going to learn how object work and how to create one.
What is an object in JavaScript?
let person = {
name: "John",
age: 25
};
*Object is a collection of data, stored as a key-value pairs like in this case name is the key and "John" is value of name,
key+value = Properties.
*#How to Access Object Values
let person = {
name: "John",
age: 25
};
delete person.age
console.log(person) =>output is name: "John"
if we want to change that key value then;
person.name = "subash"
console.log(person) => output is name: "subash"
how to add properties;
there no diff b/w change key values and add propertise
person.address = "ariyalur"; this will add address key in object;
How to use nested object
Object inside another object
let person = {
name: "John",
age: 25,
Education:{
ug : "civil"}
}
This is the nested object.
CRUD- Create Read Update Delete this is what we discussed
Top comments (0)