Skip to main content

Archive

Show more

How to create array in javascript

how-to-create-array-in-javascript


Question: How to create array in javascript

Answer:

There are mainly three ways to create an array in JavaScript which is the easiest and also the most popular. Let us discuss one by one.


First:

const color = ["Red", "Green", "Blue"];


Second:

const color = [];
color[0]= "Red";
color[1]= "Green";
color[2]= "Blue";


Third:

const colors = new Array("Red", "Green", "Blue");


We try to provide you the best content, if there is any mistake in this article or there is any mistake in code, then let us know.

Comments