GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • JS Tutorial
  • Web Tutorial
  • A to Z Guide
  • Projects
  • OOP
  • DOM
  • Set
  • Map
  • Math
  • Number
  • Boolean
  • Exercise
  • Insert an Element
  • Remove Element

This view

  • Original page
  • New address

GeezerVison is showing www.geeksforgeeks.org — JavaScript Array Examples - GeeksforGeeks

geeksforgeeks
search icon
  • Courses
  • Tutorials
  • Interview Prep
  • JS Tutorial
  • Web Tutorial
  • A to Z Guide
  • Projects
  • OOP
  • DOM
  • Set
  • Map
  • Math
  • Number
  • Boolean
  • Exercise

JavaScript Array Examples

Last Updated : 5 Aug, 2025

JavaScript array is used to store multiple elements in a single variable.

JavaScript
let a = ["HTML", "CSS", "JS"]
console.log(a)

Output
[ 'HTML', 'CSS', 'JS' ]
JavaScript-Array-Programming-Examples

Using New Keyword

JavaScript
// Declaring an array using Array Constructor
let a = new Array(3)
a[0] = "HTML"
a[1] = "CSS"
a[2] = "JS"
console.log(a)

Output
[ 'HTML', 'CSS', 'JS' ]

All the JavaScript array-related articles into three sections based on their difficulty levels: Easy, Medium, and Hard. This organization aims to help learners gradually progress from basic to more complex concepts.

Easy:

The Easy level includes articles that cover fundamental operations and straightforward tasks with JavaScript arrays.

  • Insert an Element
  • Remove Element
  • Remove Duplicates
  • Get a Value from a JSON Array
  • Replace an Item
  • Find Duplicates
  • Select a Random Element
  • Insert at Specific Index
  • Get Array Length
  • An Array of Given Size
  • Append in an Array
  • First and Last in an Array
  • Reverse an Array
  • Empty an Array in JavaScript
  • Convert an Array into a String
  • Search an Element
  • Largest in an Array
  • First N from an Array

Medium:

The Medium level includes articles that delve deeper into working with JavaScript arrays, exploring more advanced operations and methods:

  • Modify an Object's Property in Array Objects
  • Sort Object Array by Date
  • Copy Items into Another Array
  • Count Occurrences of All Items
  • Convert Array to Object
  • Compare Two Arrays
  • Add Object to Array
  • Create Comma Separated List
  • Find the Min/Max Element
  • Clone an Array
  • Create HTML List
  • Convert String to Array
  • Convert Set to Array
  • Create 2D Array
  • Sum Array Elements
  • Create 1 to N Array
  • Delete Item from Array
  • Find an Item in Array
  • Add Elements to Start
  • Loop Through Object
  • Remove Object by Property
  • Move an Array Element
  • Store Array in LocalStorage
  • Remove Empty Elements
  • Convert Byte Array to String
  • Sort Numeric Array
  • Find Object Index
  • Change the Array Value
  • Find the Most Frequent Element
  • Most Frequently Element
  • Map in Reverse Order
  • Calculate Standard Deviation
  • Find the Missing Number
  • Remove Falsy Values
  • Remove Min/Max Elements
  • Find First Non-Repeated Element
  • Find the Majority Element
  • Get All Non-Unique Values
  • Find Minimum Repeating Index

Hard:

The Hard level includes articles that cover more intricate and less common tasks

  • Remove Duplicates from Array Objects
  • Get Distinct Object Values
  • Convert Object into Array Objects
  • Convert Array of Objects to a Map
  • Split an Array into Chunks
  • Check Array for Substring
  • Remove Multiple Items
  • Find Second Largest
  • Convert Map Keys to Array
  • Group Objects by Property
  • Sort Words Alphabetical
  • Quick Sort
  • Check Value at Index
  • List Array Keys
  • Find Find Target Index
  • Merge Arrays In-Place
  • Remove Null Objects
  • Sort Array by Values
  • Find Next Smaller Element
  • Sort 1 to N Array
  • Find Largest Subarray Divisible by K
  • Find K Most Frequent
  • Count Unequal Pairs
  • Sparse Table
  • Rotation Count
  • Array from Pair Sum
  • Find Union and Intersection
  • Count Numbers Less or Equal
  • Find Median in a Stream
  • OR and AND of Elements
  • Max Profit with Share
  • K-th Largest Sum
  • Max Distance Between Element
  • Calculate Mean
  • Search Rotated Array
  • Range Sum Query
  • Rearrange in Max-Min Form
  • Transpose 2D Array
  • Longest Consecutive Sequence
  • Sort Array Objects by Property
  • Merge Sort
  • Square Root (Sqrt) Decomposition
  • Rearrange Even/Odd Positions
  • Shortest Distance Between Words
  • Filter Array Objects in ES6
  • Compare Array Objects
  • Find Object Property Values
  • Create Range Array
  • Find Nth Smallest/Largest Element
  • Store Dates in Range
  • Sort Mixed Data Type Array
  • Count Data Types
  • Find Unique Elements from Two Arrays
  • Minimum Swaps to Sort
  • Reorder an Array
  • Unique Values from Arrays
  • Swap Variables
  • Swap First and Last Elements
  • Split Map Keys and Values
  • Find the K-th Largest Sum
  • Find Max Distance Between Element
  • Unique Elements Check
  • Create Intersection of Two Arrays
  • Create Pre-Filled Array
  • Remove Objects from Associative Array
  • Ungroup Elements from Zipped Array
  • Create Unique Array with Set
  • Loop Through Array
  • Find Top Three Elements
  • Merge Two Sorted
  • Find Nth Smallest/Largest Element
  • Convert CSV to 2D Array
  • Short Circuit forEach
  • Find the Largest Subarray with Sum K
  • Left Rotate by One
  • Search Rotated Array
  • Construct an Array from Its Pair Sum Array
  • Space Optimization Using Bit Manipulations
  • Construct Array from Sum
  • Find Max Profit wih Share
  • Find K Most Occurrences

Recommended Links:

  • Interesting Facts about JavaScript Arrays
  • JavaScript Array Complete Reference
  • JavaScript Tutorial
  • Recent articles on JavaScript
Comment

Explore

    JavaScript Basics
    • Introduction3 min read
    • Variables5 min read
    • Operators4 min read
    • Control Statements4 min read
    Array & String
    • Arrays6 min read
    • Array Methods4 min read
    • String5 min read
    • String Methods8 min read
    Function & Object
    • Functions4 min read
    • Function Expression3 min read
    • Function Overloading4 min read
    • Objects4 min read
    • Constructors4 min read
    OOP
    • OOP5 min read
    • Classes & Objects4 min read
    • Access Modifiers5 min read
    • Constructor4 min read
    Asynchronous JavaScript
    • Asynchronous2 min read
    • Callbacks4 min read
    • Promises4 min read
    • Event Loop3 min read
    • Async Await Fuction3 min read
    Exception Handling
    • Error and Exceptional Handling5 min read
    • Errors Throw & Try to Catch2 min read
    • Custom Errors2 min read
    • TypeError Invalid Array.prototype.sort argument1 min read
    DOM
    • DOM8 min read
    • DOM Elements3 min read
    • Custom Events4 min read
    • Addeventlistener5 min read
    Advanced Topics
    • Closure3 min read
    • Hoisting5 min read
    • Scope4 min read
    • Higher Order Functions7 min read
    • Debugging3 min read
    Courses
    • Placement 360 Course2 min read
    • MERN Full Stack Course2 min read
    • DSA and System Design Course2 min read
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.