JavaScript Object , Contact me on : 7709330265(Whats app No)/ramkumarkhub@gmail.com
Now a days JavaScript is like the lovely scripting among us, It’s kind of interesting and practical language which people love to work.
Among many JavaScript topics JavaScript Object is like the heart of JavaScript, Everything in JavaScript is nothing but the object.
Object Contain key: value pair which means we can store data in the object in key value format.
We can store any type of data, function, Array etc. in Object.
Whenever we create new function internally the memory stored in Object form which indicate that in which position the function is stored.
There are many ways to create JavaScript object:
1. {}
let obj = {}
// Output : {}
obj.name = “ram”;
console.log(obj)
// Output: {name: “ram”}
obj.city = “pune”;
console.log(obj)
console.log(obj.city);
// Output : “pune”
2. With the help of new keyword
var person = new Object();
person.fName = “John”;
person.lName = “Doe”;
person.age = 50;
Delete specific key from JavaScript:
let person = {
fName:”John”,
fLname:”Doe”,
age:50,
};
delete person.age;
Add Specific key and value in JavaScript:
let person = {
fName:”John”,
fLname:”Doe”,
age:50,
};
person.phone = 7709330265