Review Arrays
Nice work! In this lesson, we learned these concepts regarding arrays:
- Arrays are lists and are a way to store data in JavaScript.
- Arrays are created with brackets
[]
. - Each item inside of an array is at a numbered position, starting at
0
. - We can access one item in an array using its numbered position, with syntax like:
myArray[0]
. - We can also change an item in an array using its numbered position, with syntax like
myArray[0] = "new string"
; - Arrays have a
length
property, which allows you to see how many items are in an array. - Arrays have their own methods, including
.push()
and.pop()
, which add and remove items from an array, respectively. - Arrays have many other methods that perform different functions, such as
.slice()
and.shift()
. You can read the documentation for any array method on the Mozilla Developer Networkwebsite. - Variables that contain arrays can be declared with
let
orconst
. Even when declared withconst
, arrays are still mutable; they can be changed. However, a variable declared withconst
cannot be reassigned.
Instructions
Congratulations on learning about arrays!
Tidak ada komentar:
Posting Komentar