Learn JavaScript
  • Introduction
  • Basics
    • Comments
    • Variables
    • Types
    • Equality
  • Numbers
    • Creation
    • Basic Operators
    • Advanced Operators
  • Strings
    • Creation
    • Concatenation
    • Length
  • Conditional Logic
    • If
    • Else
    • Comparators
    • Concatenate
  • Arrays
    • Indices
    • Length
  • Loops
    • For
    • While
    • Do...While
  • Functions
    • Declare
    • Higher order
  • Objects
    • Creation
    • Properties
    • Mutable
    • Reference
    • Prototype
    • Delete
    • Enumeration
    • Global footprint
Powered by GitBook
On this page
  1. Objects

Creation

There are two ways to create an object in JavaScript:

  1. literal

    var object = {};
    // Yes, simply a pair of curly braces!

    Note: this is the recommended way.

  2. and object-oriented

    var object = new Object();

    Note: it's almost like Java.

PreviousObjectsNextProperties

Last updated 4 years ago