Introduction to Array in Javascript
In this blog, we are going to explore Arrays in Javascript

Search for a command to run...
In this blog, we are going to explore Arrays in Javascript

No comments yet. Be the first to comment.
This Javascript Blog series is for beginners who wish to start their journey in Javascript. We will cover Javascript topics from basic to advanced levels and some projects to practice the concepts.
In this blog, we will explore the basic array methods in Javascript.
Scalable Wireless Distributed Consensus for Autonomous Vehicles at Unsignalized Intersections

The Ultimate VLSI Roadmap is designed to help students and professionals gain clarity in choosing a role for their future careers.

A convolutional neural network (CNN) is a type of artificial neural network used primarily for image recognition and processing, due to its ability to

Natural language processing (NLP) is a branch of artificial intelligence that helps computers understand, interpret, and manipulate human language.

Introduction to Python

An array is a special object in Javascript, that stores multiple values inside a single variable.
Let’s take a scenario where we need to store multiple variables ranging up to 100(i.e., we need to keep 100 variables). Usually, what we will
Var a = 10;
Var b =30;
Var c = 40;
.
.
.
.
.
.
.
.
.
.
.
It goes on
In the above case, there is a lot of memory space is wasted and it’s not possible to store 100 variables in the above manner it creates issues in dynamic data storage also. So, the Array concept gives a solution to this problem. Because with the array we can store multiple values inside a single variable.
We use Square brackets(i.e., []) to enclose the array of elements inside a single variable.
Example:-
let arr = [ 1, 2, 3, 6,7 ];
We can access an array of elements by using its index value.
Let’s take an example,
let arr = [1,2,3,4,5];
In the above example, if we need to access the fourth element of the array. We will access it by its index value.
The Index value starts with 0 and it goes on.

The above picture shows the array of elements with its index value.
So, if we need to access fourth element of the array. We will do it by
console.log(arr[3]); // 4
We can define an array in two methods, are
The first method is the regular method to define an array,
let arr = [ 1, 2, 3, 4 ];
The Second method is,
Step-1: First declare an empty array.
let arr = [];
Step-2: Next, using its index value - insert elements one after another.
arr[0] = “Banana”;
arr[1] = “Apple”;
arr[2] = “orange”;
console.log(arr); // [ “Banana”, “Apple”, “orange”];
In the next blog, we will explore array properties and methods.