News for hackers. Stuff that matters.
Re:Using the switch(true) pattern in JavaScript by borishn on Monday April 12, 2021 @11:18AM (#26780330)
The article is misleading, in implying that `switch(true)` is a special case: "The fundamental principle of the switch true pattern is that you can match against expressions as well as values."

It should be states as "The fundamental principle of the switch pattern in JavaScript is that you can match against expressions as well as values."

From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...:

A switch statement first evaluates its expression. It then looks for the first case clause whose expression evaluates to the same value as the result of the input expression

There are no comments on this comment yet.