Skip to main content

JavaScript Arrays

14 lessonsAbout 84 minutesBeginner

This part of the JavaScript Tutorial runs from JavaScript Arrays through to JavaScript Array flat. There are 14 lessons here, and working through them takes about 84 minutes at a steady pace.

It follows on from JavaScript Scope & Hoisting, so finish that first if you have not already — the examples below assume you are comfortable with it.

Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.

  1. 1JavaScript ArraysA JavaScript array stores several values in a single variable.
  2. 2JavaScript Array AccessJavaScript array elements are read using their index, starting at 0.
  3. 3JavaScript Array push and popJavaScript push, pop, shift and unshift add and remove elements at the ends of an array.
  4. 4JavaScript Array slice and spliceJavaScript slice copies part of an array, while splice changes the array in place.
  5. 5JavaScript Array concat and joinJavaScript concat joins two arrays together and join turns an array into a string.
  6. 6JavaScript Array SearchJavaScript indexOf and includes tell you whether a value is in an array and where it sits.
  7. 7JavaScript Array forEachJavaScript forEach runs a function once for every element in an array.
  8. 8JavaScript Array mapJavaScript map builds a new array by running a function on every element.
  9. 9JavaScript Array filterJavaScript filter builds a new array containing only the elements that pass a test.
  10. 10JavaScript Array reduceJavaScript reduce boils an array down to a single value.
  11. 11JavaScript Array findJavaScript find returns the first element that passes a test, or undefined.
  12. 12JavaScript Array some and everyJavaScript some and every check whether elements pass a test and return true or false.
  13. 13JavaScript Array sortJavaScript sort arranges the elements of an array and changes the original.
  14. 14JavaScript Array flatJavaScript flat turns a nested array into a shallower one.