else if

else if executes when an alternate condition is true.

Multiple else if statements are allowed.

The else statement is optional.

Syntax

if(condition1)
{
    code
}
else if(condition2)
{
    code
}
else if(condition3)
{
    code
...
}
else
{
    code
}

Examples

True

False

Internal

else

if

switch

try catch

External

Mozilla Developer Network

Home Menu