Open Source Tutorials - Open Source Training
Open source training & tutorials from experienced, passionate people
chrome icon firefox icon ie icon opera icon safari icon Sings in these Browsers
A- A A+

By A Web Design

Welcome, Guest
Username Password: Remember me

Difference between switch statements and if...else
(1 viewing) (1) Guest
All your queries regarding JavaScript will be solved in this forum
  • Page:
  • 1
TOPIC:

Difference between switch statements and if...else

Difference between switch statements and if...else 1 year, 2 months ago #548

  • shama
  • OFFLINE
  • Senior Boarder
  • Posts: 63
  • Karma: 0
What is the difference, besides the syntax, between the switch statements and the if...else if...else conditional statement?

Re: Difference between switch statements and if...else 1 year, 2 months ago #553

  • isaac
  • OFFLINE
  • Senior Boarder
  • Posts: 64
  • Karma: 0
A switch statement is better when you want to do something different based on a single property... This is better, shorter, more readable (and faster to run) than the equivalent if/else block... However, the switch statement does only work on a single comparison, so you need to use an if/else block if you want to compare different things or combination of things.
  • Page:
  • 1
Time to create page: 2.81 seconds
OSV Newsletter


Receive HTML?

NOTE: To prevent subscription to the OSV newsletter, uncheck the checkbox above.
Guest Blog for OSV
Free Ebook Download