🔦 Switch(true)

👋 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