Skip to Main Content
Head First JavaScript Programming, 2nd Edition
book

Head First JavaScript Programming, 2nd Edition

by Eric Freeman, Elisabeth Robson
August 2024
Beginner content levelBeginner
662 pages
17h 50m
English
O'Reilly Media, Inc.
Content preview from Head First JavaScript Programming, 2nd Edition

Chapter 4. Putting some order in your Data: Arrays

Image

There’s more to JavaScript than numbers, strings, and booleans. So far you’ve been writing JavaScript code with primitives—strings, numbers, and booleans, like “Fido”, 23, and true. You can do a lot with primitive types, but at some point you’ve got to deal with more data. Say, all the items in a shopping cart, or all the songs in a playlist, or a set of stars and their apparent magnitude, or an entire product catalog. For that you need a little more oomph. The type of choice for this kind of ordered data is a JavaScript array, and in this chapter we’re going to walk through how to put your data into an array, how to pass it around, and how to operate on it. We’ll be looking at a few other ways to structure your data in later chapters, but let’s get started with arrays.

Can you help Bubbles-R-Us?

Meet the Bubbles-R-Us company. Their tireless research makes sure bubble wands and machines everywhere blow the best bubbles. Today, they’re testing the “bubble factor” of several variants of their new bubble solution; that is, they’re testing how many bubbles a given solution can make. Here’s their data:

Image
Image

Of course, you want to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Head First JavaScript Programming

Head First JavaScript Programming

Eric T. Freeman, Elisabeth Robson
Head First HTML and CSS, 2nd Edition

Head First HTML and CSS, 2nd Edition

Elisabeth Robson, Eric Freeman

Publisher Resources

ISBN: 9781098147938Errata Page