let students = []; //empty array let colors = [‘red‘, ‘orange‘, ‘yellow‘]; // strings let lottoNums = [19,22,34]; //numbers let stuff = [true, 68, ‘cat‘, null]; //mixed array
let colors = [‘red‘, ‘blue‘, ‘green‘]; color[0] = ‘red‘; color[3] = ‘blue‘;
const Eggs = [‘brown‘, ‘brown‘]; Eggs.push(‘purple‘); Eggs[0] = ‘green‘; myEggs = [‘nlue‘, ‘pink‘]; //ERROR ! the reference was changed
nested arrays
const board = [ [‘O‘, null, ‘X‘], [‘H‘, ‘A‘, ‘N‘], ] board[1][0] = ‘H‘
原文:https://www.cnblogs.com/LilyLiya/p/14249739.html