Switch(true) in js

PreetiPreeti
1 min read

Well i was writing this small code to check some conditions using a switch statement, when i came acoss this mundane JS concept where we use Switch(expression) and then the following cases for it,

in Java, i remember using switch(variable) which will lead to the execution of seperate conditionals based on different values of this variable.

so in order to execute the switch statements in js, we need an expression, which will always evalutes to true.

0
Subscribe to my newsletter

Read articles from Preeti directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Preeti
Preeti