May 2019
Beginner to intermediate
650 pages
14h 50m
English
The main data structure you will use to store one-dimensional data is the JavaScript array. An array of values is all you need to make a simple bar chart or line chart. With an array of arrays you can create a scatterplot.
Arrays are created by declaring a list of items within brackets, or simply a pair of opening-closing brackets if you want to start with an empty array:
const colors = ["red", "blue", "green"];const geocoords = [27.2345, 34.9937]; const numbers = [1,2,3,4,5,6]; const empty = [];
You can then access the items of an array using an array index, which starts counting from zero:
const blue = colors[1]; const latitude = geocoords[0];
Each array has a length property that returns the number of elements. It's very useful ...
Read now
Unlock full access