Source @ github

switch

switch

Description

switch (mixed expression)

Parameters

Name Description Type Default Optional
expression The expression to check. mixed No

Examples

Example #1 – switch example
var expr = "Hello"; switch (expr) { case "Hello": console.log('expr was set to "Hello"'); break; case "World": console.log('expr was set to "Wrold"'); break; case "foo": case "bar": console.log('expr was set to "foo" or "bar"'); break; default: console.log('The value of expr was not matched.'); }

External references