DEV Community

Gayathri.R
Gayathri.R

Posted on

What is object

an object is a variable that can hold multiple values, often referred to as a collection of key-value pairs. These key-value pairs represent properties and methods of the object.
Properties are variables associated with an object, describing its characteristics.
Methods are functions associated with an object, defining its behaviors or actions.
Example:
Consider a real-world object like a "car." In JavaScript, you can represent this car as an object:
JavaScript

const car = {
  type: "Fiat",
  model: "500",
  color: "white",
  weight: "850kg",
  start: function() {
    console.log("Engine started!");
  },
  drive: function() {
    console.log("Car is driving.");
  }
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)