> For the complete documentation index, see [llms.txt](https://strctr.gitbook.io/programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://strctr.gitbook.io/programming/01-languages/javascript/01-language/a-core/a2-operators-and-statements/04-switch.md).

# 04. switch

После вычисления выражения в `switch` результат сопоставляется с каждой меткой при помощи `===`. Значением метки может быть что угодно.

```javascript
function compare(x, y) {
  switch (true) {
    case x < y:
      return -1;
    case x === y:
      return 0;
    default:
      return 1;
  }
}
```
