Skip to Main Content
Web Coding & Development All-in-One For Dummies, 2nd Edition
book

Web Coding & Development All-in-One For Dummies, 2nd Edition

by Paul McFedries
January 2024
Beginner content levelBeginner
848 pages
18h 2m
English
For Dummies
Content preview from Web Coding & Development All-in-One For Dummies, 2nd Edition

Chapter 4

Controlling the Flow of JavaScript

IN THIS CHAPTER

Bullet Understanding how you control the flow of JavaScript

Bullet Setting up your code to make decisions

Bullet Understanding code looping

Bullet Setting up code loops

Bullet Avoiding the dreaded infinite loop

A good programmer is someone who always looks both ways before crossing a one-way street.

— DOUG LINDER

When the web browser comes across a <script> tag, it puts on its JavaScript hat and starts processing the statements. Not surprisingly, the browser doesn't just leap randomly around the script, parsing the statements willy-nilly. That would be silly. No, the browser puts its head down and starts processing the statements one at a time: the first statement, the second statement, and so on until there’s no more JavaScript left to parse.

That linear statement-by-statement progression through the code makes sense, but it doesn’t fit every situation. Sometimes you want your code to test some condition and then run different chunks of code depending on ...

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

Web Coding & Development All-in-One For Dummies

Web Coding & Development All-in-One For Dummies

Paul McFedries
Programming PHP, 4th Edition

Programming PHP, 4th Edition

Kevin Tatroe, Peter MacIntyre

Publisher Resources

ISBN: 9781394197026Purchase Link