Scripting Master Logo
Learn Scripting Languages from the Master!

Code blocks in JavaScript

Home : JavaScript > Introductory concepts > Basics of JavaScript > 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