Open In App

What is an Object in JavaScript ?

Last Updated : 12 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Objects, in JavaScript, are the most important data type and form the building blocks for modern JavaScript. These objects are quite different from JavaScript’s primitive data types (Number, String, Boolean, null, undefined, and symbol) in the sense that these primitive data types all store a single value each (depending on their types).

Syntax:

new Object(value)
Object(value)
let object_name = {
key_name : value,
...
}

Example: Here, the variable person is assigned an object representing information about a person. It has three key-value pairs: name: "John", age: 30, and city: "New York". The object properties are accessed using dot notation (person.name), and the value "John" is then logged to the console.

Javascript




let person = {
    name: "John",
    age: 30,
    city: "New York"
};
console.log(person.name); // Output: John


Output

John

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads