Do I still need to use break after I use return in switch/case?

Viewed 3202

switch (input) {
  case 1: 
    return "this is one";
    break;
    
  default:
    break;
}

can return break the code? Or it does what break does after return the result?

1 Answers

return terminates your function, so the code won't continue executing (and potentially falling through to the next case block). There's no point in using break in such a situation.

Related