The switch construction is used to compare a value for equality with different options.
In this case, equality is implied in the sense of the operator strict equality
===, it cannot compare with a regular expression or somehow else. That is, the values must be of the same type for equality to hold.
If the condition matches, then the code block📟 associated with the corresponding
case is executed. If none of the conditions match, then the code specified in the
default block, if any, is executed. To exit the construction, use the
break command. If you do not specify it, the code block is automatically executed in the next
case, etc. Therefore, we use
break in our scripts, so as not to run the interpreter over all
cases, thereby reducing the performance of the script.
switch construct has one or more
case blocks and an optional
It looks like this:
n - this is boolean condition.
Thanks goes to these wonderful people (emoji key):
🐛 🎨 🖋
🖋 🐛 🎨