Code blocks in JavaScript

A code block simply consists of grouped statements with curly braces ({ }). For example, statements grouped in a loop is referred to as a code block:

While loop code block

A code block can also be created with statements grouped in a condition:

If condition code block

Finally statements grouped in a function also create a code block:

Function code block