0% found this document useful (0 votes)
52 views15 pages

174 WDB Arrays

Arrays are ordered collections of values that can be accessed via indexes. They are commonly used to store lists of comments, levels in a game, songs, etc. Arrays have built-in methods like push, pop, shift, unshift to modify them. Additional methods include concat, includes, indexOf, join, reverse, slice, splice, sort. Const can be used with arrays because although the values inside may change, as long as the reference to the array remains the same. Arrays can also be nested by storing one array inside another.

Uploaded by

Aiko Yukimura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views15 pages

174 WDB Arrays

Arrays are ordered collections of values that can be accessed via indexes. They are commonly used to store lists of comments, levels in a game, songs, etc. Arrays have built-in methods like push, pop, shift, unshift to modify them. Additional methods include concat, includes, indexOf, join, reverse, slice, splice, sort. Const can be used with arrays because although the values inside may change, as long as the reference to the array remains the same. Arrays can also be nested by storing one array inside another.

Uploaded by

Aiko Yukimura
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Web Developer Bootcamp

JS Arrays
OUR FIRST DATA STRUCTURE
ARRAYS
Ordered collections of values.
List of comments on IG post
Collection of levels in a game
Songs in a playlist
Creating Arrays
PLEASE DROP BY AND SEE ME!
ARRAYS ARE INDEXED
Doc Dopey Bashful Grumpy Sneezy Sleepy Happy

0 1 2 3 4 5 6
Each element has a corresponding index
(counting starts at 0)
Arrays Are Indexed
Modifying Arrays
ARRAY METHODS

Push - add to end


Pop - remove from end
Shift - remove from start
Unshift - add to start
YOU'LL GET USED TO THE NAMES EVENTUALLY!
MORE METHODS
concat - merge arrays
includes - look for a value
indexOf - just like string.indexOf
join - creates a string from an array
reverse - reverses an array
slice - copies a portion on an array
splice - removes/replaces elements
sort - sorts an array
CONST

AND

ARRAYS
WHY DO PEOPLE USE CONST WITH ARRAYS??
THE VALUES CAN CHANGE
AS LONG AS THE REFERENCE REMAINS THE SAME

myEggs
THE VALUES CAN CHANGE
AS LONG AS THE REFERENCE REMAINS THE SAME

myEggs
THE VALUES CAN CHANGE
AS LONG AS THE REFERENCE REMAINS THE SAME

myEggs
THE VALUES CAN CHANGE
AS LONG AS THE REFERENCE REMAINS THE SAME

myEggs
NESTED ARRAYS
We can store arrays inside other arrays!
NESTED
ARRAYS

You might also like