JS: Object Overview

By Xah Lee. Date: . Last updated: .

What is javascript object

A JavaScript Object is a collection of key-and-value pairs. e.g. {a:1, b:2}. Each key-and-value pair is called a Property.

Data object and special-purpose object

JavaScript objects can be categorized into 2 kinds:

Data object

collection of key-and-value pairs. e.g. {a:1, b:2}

also known as Object Object.

Special-purpose object
  • Special purpose and may have internal data.
  • For example, function, date, regex, etc, are specialized objects.
  • They have special properties and behaviors.
  • But they still have the feature of holding key-and-value pairs.

Prototype of an object (aka parent of an object)

This is called Prototype-Based Object System.

Is extensible

Each object has a special true/false value attached called the [[isExtensible]] internal slot. It specifies whether new properties can be added to the object.

Source of object

It is useful to distinguish objects by where they came from. We have the following sources:

Standard Object

Objects from the JavaScript language. e.g. arrays, functions, dates, regex, etc.

Hosted Object

Objects from the hosting environment. e.g. in Browser, there's Browser's Window Object. In deno, there is deno object, with properties such as version etc.

User-defined Object