JavaScript Array Examples
Last Updated :
20 Nov, 2024
Improve
JavaScript array is used to store multiple elements in a single variable.
let a = ["HTML", "CSS", "JS"]
console.log(a)
Output
[ 'HTML', 'CSS', 'JS' ]

Using New Keyword
// 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: