Member-only story

This Is What You Must Know About JS Arrays

Kritika Sharma
4 min readFeb 9, 2021

--

Javascript Array Essential Methods Explained with Examples.

Arrays are the most commonly used data structure in any language. As we already know they’re special variables that can hold more than one value at a time. Javascript Arrays are no different, although, an essential thing to know about them is that Javascript Arrays are special kinds of Objects. Now, because of this, you can have variables of different types in the same Array. For instance,

arr[0] = cars; //cars = ['Bentley', 'Mustang'] 
arr[1] = Date.now;
arr[2] = aFunction;

Besides primitive data types, you can also store objects, functions, even arrays inside of an Array.

Now, there’s a lot of stuff you can do with Javascript Arrays using a wide range of methods they offer. However, the following 4 methods are absolutely essential to know.

https://www.30secondsofcode.org/

General Overview:

Okay, before we get into the code, let me first explain to you with the help of this beautiful picture, how these methods work, and to be honest, this image explains it all.

.map( ),

Input: Array of Squares.

Output: Array of Circles.

Process: We are mapping or transforming the array elements into something different…

--

--

Kritika Sharma
Kritika Sharma

Written by Kritika Sharma

Tech PM/Soft Eng by profession, Learner by Passion. I write to promote financial literacy, share technical insights, and career advancement tips that I learn!:)

No responses yet