May 2022
Beginner
304 pages
6h 49m
English
In Chapter 2, we saw that strings can be thought of as sequences of characters in a particular order. In this chapter, we’ll learn about the array data type, which is the general JavaScript container for arbitrary elements in a particular order. We’ll start by explicitly connecting strings and arrays via the String split method (Section 3.1), and then learn about various array methods throughout the rest of the chapter.
So far we’ve spent a lot of time understanding strings, and there’s a natural way to get from strings to arrays via the split method:
> "ant bat cat".split(" "); // Split a string into a three-element array. [ 'ant', 'bat', 'cat' ]
We see from this result that split ...
Read now
Unlock full access