/
🔦

Switch(true)

javascript

You can use switch (true) instead of multiple if/else statements

js
const x = 1
switch (true) {
case: x === 1 {
// ...
break
}
case: 5 < x {
// ...
break
}
}
Edit this page
Want to make your own site like this?
Try gatsby-theme-code-notes by Zander Martineau.
Notes on code. My second brain, by Zander Martineau.