0

Which is better: switch statement or if else statement

19th May 2017, 2:07 PM
GARG
GARG - avatar
2 Antworten
+ 4
if() and else{} can use && and ! easily.... While switch not but shorten....
19th May 2017, 2:13 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 2
Switch statements are used for aesthetics & code readability. Instead of using 10 or more "else if"s, if you use a switch statement , you need fewer keystrokes as well. There is no performance advantage of using one over the other. I use JavaScript.
19th May 2017, 2:16 PM
droste
droste - avatar