0
If/else statement or switch statement ??
in JavaScript, between d regular if/else statement and d switch statement, which is beta and in which case will one be beta Dan d other???
3 Respuestas
+ 2
Switch statements are strict in that you need to provide a default fall through case but they also give you more flexibility in that if statements work with boolean, switch statements can take on a larger variety of case statements for a Serene and known set of parameters a switch statement is preferred but when there are a variety of unknowns then if statements will work to your advantage.
+ 2
From another point of view, your code should always be understandable by humans (just in case someone else has to maintain your code)... so a switch statement is far less complicated to read than a nested if-elseif-elseif-else statement.
+ 1
thanks guys