Theme Layout

Boxed or Wide or Framed

Wide

Theme Translation

Display Featured Slider

Featured Slider Styles

Display Grid Slider

yes

Grid Slider Styles

Display Trending Posts

Display Author Bio

Display Instagram Footer

off

Dark or Light Style

Light

Blog Archive

Powered by Blogger.

Monday, February 20, 2017

[JavaScript] Switch Statement


# JavaScript Switch Statement


● The JavaScript Switch Statement

Use the switch statement to select one of many blocks of code to be executed.

● The break keyword

When JavaScript reaches a break keyword, it breaks out of the switch block.
this will stop the execution of more code and case testing inside the block.
When a match is found, and the job is done, it's time for a break. There is no need for more testing. It is not necessary to break the last case in a switch block. The block breaks there anyway.

● The default keyword

The default keyword specifies the code to run if there is no case match.


The default case does not have to be the last case in a switch block.

● Common Code Blocks

Sometimes programmer will want different switch cases to use the same code.
In this example case 4 and 5 share the same code block, and 0 and 6 share another code block.


QuickEdit
Unknown
0 Comments
Share This Post :

You Might Also Like

No comments:

Post a Comment

Follow @SunriseSunsetBlog