Wednesday, December 31, 2008

Javascript switch statement

There are instances when you have to write a code which will have endless "if" ..."else if" ... "else if" statements. While you can do like this, javascipt provide a switch statement that makes the code look cleaner.

Let us look at the example the prints the day of the week. If you run the above script it should display the day of the week.

You can try this example online here.
http://www.referencedesigner.com/tutorials/js/js_8.php

No comments: