JavaScript Object Literal Explained

JavaScript Logo

Object Literal – Defines an object using key-value pairs. It's the most common way to create objects in JavaScript.

๐Ÿ‘‰ Syntax

const person = {
  name: 'John',
  age: 30,
  isAdmin: true
};

๐Ÿงช Example

const car = {
  brand: 'Toyota',
  model: 'Corolla',
  year: 2020
};
console.log(car.brand);

Comments