# JavaScript data types and data structures

Programing languages all have built-in data structures, but these often differ from one language to another. This article attempts to list the built-in data structures available in JavaScript and what properties they have. These can be used to build other data structures. Wherever possible, comparisons with other languages are drawn.

# Dynamic typing

JavaScript is a loosely typed and dynamic language. Variables in JavaScript are not directly associated with any particular value type, and any variable can be assigned(and re-assigned) values of all types.

# Data and Structure types

The latest ECMAScript standard defines nine types:

  • Six Data Types that are primitives, checked by typeof operator:
    • undefined: typeof instance === "undefined"
    • Boolean: typeof instance === "boolean"
    • Number: typeof instance === "number"
    • String: typeof instance === "string"
    • BigInt: typeof instance === "bigint"
    • Symbol: typeof instance === "symbol"
  • Structural Types:
    • Object: typeof instance === "object". Special non-data but Structural type for any constructed object instance also used as data structures: new Object, new , new Map, new Set, new WeakMap, new WeakSet, new Date and almost everything made with new keyword.
    • Function: a non-data structure, though it also answers for typeof operator: `typeof instance === "function"'. This is merely a special shorthand for Functions, through every Function constructor is derived from Object constructor.
  • Structural Root Primitive:
    • null: typeof instance === "object". Special primitives type having additional usage for its value: if object is not inherited, the null is shown.