Array method in JavaScript

Array method in JavaScript

What is an array?

An array is a single variable that is used to store different elements.

example:-

let array = [ 1, "Hello", "Ashish", "I", "am", "learning", "JavaScript"];

How many ways declare an array?

1:- using an array literal:- The easiest way to create an array is by using an array literal []

example:- let fruit = ["Mango", "Orange", "Apple"];

2:- Using the new keyword:- you can declare an array with different syntax as well with the help new keyword.

example:- let array = new Array2 [ "Mango", "Orange", "Apple"];

let's see the more number of examples of arrays

// Example of empty array let Array = [ ];

// Example of numbers const Array = [ 1, 3, 5, 32, 5];

// Example of String // in string you can write double quote "" or single quote '' as well const stringArray = [ 'Mango', 'Ashish', 'Mohan'];

// Example with mixed number and array const newData = ['Ashish', 'FSJS', 2, 'Contact', 9026xxxxx];