DEV Community

Code_Regina
Code_Regina

Posted on

|JavaScript| JavaScript: Arrays

          -Introducing Arrays
          -Array Random Access
          -Push and Pop
          -Concat, IndexOf, includes and reverse
Enter fullscreen mode Exit fullscreen mode

Introducing Arrays

Arrays are ordered collections of values.


let students = []' 

let colors = ['red', 'orange', 'yellow']; 

let lottoNums = [19, 22, 56, 12, 51]; 

let stuff = [true, 68, 'cat', null]; 

Enter fullscreen mode Exit fullscreen mode

Array Random Access

Arrays are indexed meaning they hold values from
0 - 255

Alt Text

Push and Pop

Arrays have a lot of different methods for using arrays in data structures.
Some of the most common array methods are known as

push - add to the end

pop - remove from the end

shift - remove from start

Unshift - add to start

Concat, IndexOf, includes and reverse

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 and replaces elements

sort - sorts an array

Top comments (0)