Object is a data type, which is used to hold or point to more than one data. Object is structured in key value pair.
It can hold n number of data in the key-value format.
Object is a string data type in programming concept.
An object can be created with figure brackets {…} with an optional list of properties or can be created using a new keyword. A property is a “key: value” pair, where key is a string (also called a “property name”), and value can be anything.
let obj= new Object(); // "object constructor" syntax
let obj = {}; // "object literal" syntaxWe can add some properties into {} as “key: value” pairs:
let obj= { // an object
name: "Alex", // by key "name" store value "Alex"
age: 30 // by key "age" store value 30
};There’s an another way “square bracket notation” that works with string:
let user = {};
// set
user["likes birds"] = true;
// get
alert(user["likes birds"]); // true
// delete
delete user["likes birds"];

0 Comments