Three Ways to Create Objects in JavaScript

Almost everything in Javascript is an object, whether it’s an array or a function. In this post, we’ll learn three different ways to create objects in JavaScript:

  1. Object Literals.
  2. New Keyword.
  3. Classes.
You may also like: Object-Oriented JavaScript: Objects, Encapsulation, and Abstraction (With Examples).

Object Literals

A JavaScript object literal is a comma-separated list of name-value pairs wrapped in curly braces. Object literals encapsulate data, enclosing it in a tidy package.