what is array in js code example

Example 1: how to make an array in javascript

var names = ["Sanjith", "Pranav", "Aadya", "Saharsh"]

Example 2: js array

const users = ["Mark", "Greg"];

Example 3: js array

var colors = [ "red", "orange", "yellow", "green", "blue" ]; //Array

console.log(colors); //Should give the whole array
console.log(colors[0]); //should say "red"
console.log(colors[1]); //should say "orange"
console.log(colors[4]); //should say "blue"

colors[4] = "dark blue" //changes "blue" value to "dark blue"
console.log(colors[4]); //should say "dark blue"
//I hope this helped :)

Example 4: array in js

var array_name = [item1, item2, ...];      
//Used to store more than 1 items

Tags:

Java Example