JavaScript Control Statements Reference


As we discussed in Chapter 2, JavaScript has the usual control statements you would expect for a C-like language:

  • do loops
  • for and for/in loops
  • while loops
  • if-else conditionals
  • switch conditionals

In addition, JavaScript provides ways to manage your loop iterations, break out of loops entirely, and even limit the scope of your loops.

In this chapter we’ll provide a solid reference for all JavaScript control statements, in alphabetical order. For detailed discussions of these statements, see Chapter 2.


The break statement terminates the current loop or the current label or ...

Get JavaScript Programmer's Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.