JavaScript Objects

An object is a data structure that stores data and methods in key-value pairs, similar to a dictionary or a map in other programming languages. Objects are used to represent real-world entities, such as people, cars, and houses.

JavaScript Object Syntax

The syntax for a JavaScript object is as follows:

const objectName = {
  property1: value1,
  property2: value2,
  ...
};

The objectName is the name of the object. The properties are the properties of the object. The values are the values of the properties.

Here is an example of a JavaScript object:

let person = {
    firstName: "F C",
    lastName: "Koli",
    age: 30
};
ADVERTISEMENT
ADVERTISEMENT