DEV Community

Bhuvana Sri R
Bhuvana Sri R

Posted on

Object in JavaScript

What is object ?

An object is a fundamental data type used to store collections of related data and functionality. Objects are essentially collections of key-value pairs.
Keys (or Property Names):
These are unique identifiers, typically strings or Symbols, used to name and access the associated values.
Values (or Properties):
These can be any JavaScript data type, including primitive values (numbers, strings, booleans, null, undefined), other objects, or even functions. When a value is a function, it's referred to as a method.
Example :

const person = {
  firstName: "John",
  lastName: "Doe",
  age: 30,
  greet: function() {
    console.log("Hello, my name is " + this.firstName);
  }
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)