Explain arrays in JavaScript

Technology CommunityCategory: JavaScriptExplain arrays in JavaScript
VietMX Staff asked 3 years ago

An array is an object that holds values (of any type) not particularly in named properties/keys, but rather in numerically indexed positions:

 let arr = ["hello world", 42, true]; 
 
 arr[0]; // "hello world" 
 arr[1]; // 42 
 arr[2]; // true 
 arr.length; // 3 
 
 typeof arr; // "object"