Working with Arrays in JavaScript…

isuru sellahewa
Jul 31, 2021

JavaScript array is an object that represents a collection of similar types of elements.

There are 3 ways to construct an array in JavaScript

  1. By array literal
  2. By creating an instance of Array directly (using the new keyword)
  3. By using an Array constructor (using a new keyword).

There are some methods in arrays to perform some important operations such as adding new elements to an array, Finding elements in an array, removing elements from arrays, splitting arrays, combining arrays, etc.

We can use push, unshift, splice methods for adding elements to arrays.

Also we can use indexOf,lastIndexOf methods to finding elements in arrays.

also we can use pop, shift methods for removing elements from an array.

Also there are so many methods like these when working with arrays…

--

--