JavaScript: Create Object

By Xah Lee. Date: . Last updated: .

There are 3 ways to create a data object.

Object Literal Expression

{} → Most useful, when you want to use it as a set of key/value pairs for data.

[see Object Literal Expression]

Object.create()

Object.create() → Most powerful and flexible way to create object, because you can specify parent object, properties, property attributes, in one place.

[see Object.create]

Create Object by Operator “new”

new function_name() → complex behavior. Most useful when you are writing a object-oriented library.

[see Operator “new”]

JavaScript Object and Inheritance

BUY
ΣJS
JavaScript in Depth

JavaScript in Depth

Basic Syntax

Value Types

Variable

String

Function

Property

Object and Inheritance

Array

Constructor/Class

Iterable 🌟

Misc