Switch statements: do you need the last break? (Javascript mainly)
Posted
by Jon Raasch
on Stack Overflow
See other posts from Stack Overflow
or by Jon Raasch
Published on 2010-04-28T13:28:39Z
Indexed on
2010/04/28
13:33 UTC
Read the original article
Hit count: 310
When using a switch()
statement, you add break;
in between separate case:
declarations. But what about the last one?
Normally I just leave it off, but I'm wondering if this has some performance implication I'm not thinking about?
I've been wondering about this for a while and don't see it asked elsewhere on Stack-O, but sorry if I missed it.
I'm mainly asking this question regarding Javascript, although I'm guessing the answer will apply to all switch()
statements.
© Stack Overflow or respective owner