The
switch
statement evaluates an expression, matching the expression's value to acase
clause, and executes statements associated with thatcase
, as well as statements incases
that follow the matchingcase
.(c) MDN
🐊Putout plugin adds ability to find and remove duplecate case.
npm i @putout/plugin-remove-duplicate-case
{
"rules": {
"remove-duplicate-case": "on"
}
}
switch(x) {
case 5:
console.log('hello');
break;
case 5:
console.log('zz');
break;
}
switch(x) {
case 5:
console.log('hello');
break;
}
MIT