Statements and declarations

case clause

Try the free JavaScript compiler

A switch label that is compared with the discriminant using strict equality during case selection. Once execution has begun, subsequent case bodies may execute without their labels matching.

Formal Syntax & Structure

javascript syntaxjavascript
case expression: statements

Working Example

Example Snippetjavascript
switch (1) { case "1": console.log("text"); break; case 1: console.log("number"); break; }
JavaScript Reference