🔦 Switch(true)
06 Jan, 2021
👋 FYI, this note is over 6 months old. Some of the content may be out of date.
You can use switch (true)
instead of multiple if/else
statements
const x = 1
switch (true) {
case: x === 1 {
// ...
break
}
case: 5 < x {
// ...
break
}
}
← Back home