Open In App
Related Articles

Introduction to Built-in Data Structures in JavaScript

Like Article
Save Article
Report issue

JavaScript (JS) is the most popular lightweight, interpreted compiled programming language, and might be your first preference for Client-side as well as Server-side developments.

Let’s see what inbuilt data structures JavaScript offers us:

Data Structure

Internal Implementation

Static or Dynamic

JavaScript Arrays

Contiguous Memory Allocation

Dynamic Nature

JavaScript Strings

Array of Unicode characters

Dynamic Nature

JavaScript Objects

Hashing key-value pair

Dynamic Nature

JavaScript Sets

Hash Tables or Search trees

Dynamic Nature

JavaScript Maps

Hash Tables

Dynamic Nature

JavaScript Arrays:

  • An array is a collection of items of the same variable type stored that are stored at contiguous memory locations.
  • Each item in an array is indexed starting with 0.

JavaScript Strings: There are two ways to create a string in Javascript:

  • By string literal
  • By string object

JavaScript Objects: There are different ways to create new objects:

  • Create a single object, using an object literal.
  • Create a single object, with the keyword new.
  • Define an object constructor, and then create objects of the constructed type.
  • Create an object using Object.create().

JavaScript Sets:

  • A set is a collection of items that are unique i.e no element can be repeated. Set in ES6 are ordered: elements of the set can be iterated in the insertion order.
  • Set can store any type of value whether primitive or objects
  • it: It is an iterable object whose all elements are added to the new set created, If the parameter is not specified or null is passed then a new set created is empty.

JavaScript Maps:

  • Map is a collection of elements where each element is stored as a Key, value pair. Map objects can hold both objects and primitive values as either key or value
  • it – It is any iterable object whose values are stored as key, value pair, If the parameter is not specified then a new map created is Empty

Last Updated : 19 Sep, 2023
Like Article
Save Article
Share your thoughts in the comments
Similar Reads