Array and Utility Functions in JavaScript

Introduction

Normally, an array is the name given to a data structure that contains data elements of a similar type. However, in JavaScript, an array can contain elements of different types. All these elements are stored in a contiguous memory location. For example, below are two valid arrays in JavaScript:

// Different types of elements in an array
array_one = ["Car", "Bus", "Truck", 18.0, 90]

// Same type of elements in an array
array_two = ["Car", "Bus", "Truck"]

Let’s start exploring the different methods we can use on arrays in JavaScript.

Basic operations on arrays

In this section, we will explore some basic operations that can be performed on arrays, such as creating an array, printing the elements of an array, accessing an element from an array, and so on.

Get hands-on with 1200+ tech skills courses.