
Understanding Objects in JavaScript
The fact that "everything in JavaScript is an object" is inaccurate, Objects contain six or seven sub types, it dependent on your viewpoint. Functions are one of the sub-type of object and it behaves like object, you can add properies to the function. If we discuss the if statement and the loop( for while do while) in JavaScript, they are not objects,when you check the type, the result will be visible to you. Objects are collection of key/value pairs. The values can be accessed as properties ,via .propName or ["propName"]. let person={ name:"Bhupesh", isActive:true, isBloging:true, education:"bachelor of technology" }; person["name"] or person.name, there are two ways to access the object. person.name="Rohit"; console.log(person.name); This will update the person name from Bhupesh to Rohit. person.city = "Bageshwar"; // This will Add a new property 'Bageshwar' console.log(city); person.age=30; delete person.age; console.log(person);
Continue reading on Dev.to Webdev
Opens in a new tab



