medium
NodeJS Medium​
What is Object in JavaScript?
In JavaScript, Object
is a data type that allow us to store data and organize data using key-value
pairs.
We can create object using object literal syntax, which involves enclosing key-value pairs with in curly braces {}
.
Compare Object with a cup, for example. A cup is an object, with properties. A cup has a color, design, weight, material that is make it, etc. The same way, JavaScript objects can have properties, which define their characteristics.
Ex :​
const user = {
name: "ABC",
age: 30,
isStudent: false,
sayHello: function () {
console.log("Hello ABC!");
},
};