[thelist] Switch statement

Amazon Paulo Amazon.Paulo at Amazoniacelular.com.br
Fri Jul 19 07:30:01 CDT 2002


Hi,

I've been using switch statement (javascript) the following way:

switch (foo){
	case 'blah':
		doSomething();
		break;
	case 'bleh':
		doSomeOtherThing();
		break;
}

Is 'break' really needed? I think that when the first condition ("blah") is
satisfied, the second one will never happen. Shouldn't it be this way?

I'm asking that because when I forgot to use 'break' I had a lot of
problems. The browser executed the statements for the first condition and
also the others.

Paulo Guedes



More information about the thelist mailing list