Statements and declarations

else if chain

Try the free JavaScript compiler

An else clause containing another if. Conditions are considered in source order; a selected branch prevents evaluation of later conditions in that chain.

Formal Syntax & Structure

javascript syntaxjavascript
if (a) { first } else if (b) { second }

Working Example

Example Snippetjavascript
if (false) { console.log(1); } else if (true) { console.log(2); }
JavaScript Reference