JS ARRAYS Flashcards
What are arrays used for?
Arrays are used for storing a list values within one variable, are sorted by position
Describe array literal notation.
var array = [array0, array1, array2]
How are arrays different from “plain” objects?
Objects are used to represent a “thing” in your code. That could be a person, a car, a building, a book, a character in a game — basically anything that is made up or can be defined by a set of characteristics. In objects, these characteristics are called properties that consist of a key and a value.
vs
We use arrays whenever we want to create and store a list of multiple items in a single variable. Arrays are especially useful when creating ordered collections where items in the collection can be accessed by their numerical position in the list.
What number represents the first index of an array?
0, memory space
Needs to move 0 spaces to get first value
What is the length property of an array?
Shows how many values are inside an array
How do you calculate the last index of an array?
array[array.length-1]
length property