Q:

javascript array syntax

// Javasscripts Arrays are not fixed length
var person = [];
person[0] = "John";
person[1] = "Doe";
person[2] = 46;

var x = person.length;     // person.length will return 3
var y = person[0];         // person[0] will return "John"
3
let fruits = ['Apple', 'Banana']

console.log(fruits.length)
// 2
6

var cars = ["Saab", "Volvo", "BMW"];
 
2
function func() {
  return [5, "string", {a: 7}];
}
1
var array_name = [item1, item2, ...];      
//Used to store more than 1 items
0

New to Communities?

Join the community