Object - Data Type

An array is a special type of object and is a reference data type.
Arrays should be used when you have ordered data.


let people = ["steve"] 
let array2 = people
alert ( people ==== array2 ) // two variable references
people.push ("john")
alert ( array2 ) // "steve","john"


var people = []; 
people[0] = "steve";
people[1] = "john";
people[2] = "david";

This is the array literal

var people = ["steve", "john", "david"]; 

This uses the keyword Array

var people = new Array("steve", "john", "david"); 


Trailing Comma

Arrays can include a trailing comma

var people = [ 
   "steve",
   "john",
   "david",
];




© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext