JavaScript Arrays

Introduction

In this blog, I will walk through the different array methods in Javascript which we will use on a daily basis.

What is JavaScript Array?

The JavaScript Array class is a global object that is used in the construction of arrays using high-level, list-like objects.

A JavaScript array is a list-like object that enables the programmer to traverse and modify the data. An array's size can be any length and it can also contain variables of different data types. These factors make them unsuitable for achieving lightweight, perfectly sized storage. However, they do offer other benefits which you might want to consider before choosing an alternative type of data.

javascript - array defined

var carmodels = ["Tesla", "Audi", "BMW", "Benz"];

Array Methods
 

Methods Description
 push()  Add a new element at the end.
 pop()  Removes the last element of an array.
 splice()  Adds elements in a specified way and position.
 slice()  Pulls a copy of a portion of an array into a new array
 toString()  Converts elements to strings.
 shift()  Remove the first element of an array.
 reverse()  Reverse the order of an element in an array.
 concat()  Join several arrays into one.
 join()  Combine elements of an array into a single string and return the string.
 indexOf()  Returns the first position at which a given element appears in an array.
 lastIndexOf()   Gives the last position at which a given element appears in an array.
 valueOf()   Returns the primitive value of the specified object.
 sort()  Sorts elements alphabetically.
 unshift()   Adds a new element to the beginning

Thank you for reading, please let me know your questions, thoughts, or feedback in the comments section. I appreciate your feedback and encouragement.

keep learning ...!