filmov
tv
JavaScript switch case Statement | switch Statement in JavaScript - JavaScript Tutorial 36
![preview_player](https://i.ytimg.com/vi/wEOWESLWGWI/maxresdefault.jpg)
Показать описание
Notes for You:: JavaScript switch case statement
- Browser executes the case whose label matches the expression given in a switch case parenthesis.
- When there are more than one alternative choices, we use switch case statement.
Syntax:
switch(expression){
case label-1:{
statements;
}
break;
case label-2:{
statements;
}
break;
…
default:{
statements;
}
}
Example Code:
var choice = 1;
switch(choice){
case 1:{
}break;
case 2: {
}break;
case 3:{
}break;
default:{
}break;
}
Output:
Ceiling fan is on
=========================================
Follow the link for next video:
JavaScript Tutorial 37 - How to Trace or Debug JavaScript code in Google chrome
Follow the link for previous video:
JavaScript Tutorial 35 - if else if ladder statement in JavaScript
=========================================
JavaScript Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
jQuery Tutorials Playlist:-
jQuery UI Tutorials Playlist:-
Bootstrap Tutorials Playlist:-
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial
- Browser executes the case whose label matches the expression given in a switch case parenthesis.
- When there are more than one alternative choices, we use switch case statement.
Syntax:
switch(expression){
case label-1:{
statements;
}
break;
case label-2:{
statements;
}
break;
…
default:{
statements;
}
}
Example Code:
var choice = 1;
switch(choice){
case 1:{
}break;
case 2: {
}break;
case 3:{
}break;
default:{
}break;
}
Output:
Ceiling fan is on
=========================================
Follow the link for next video:
JavaScript Tutorial 37 - How to Trace or Debug JavaScript code in Google chrome
Follow the link for previous video:
JavaScript Tutorial 35 - if else if ladder statement in JavaScript
=========================================
JavaScript Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
jQuery Tutorials Playlist:-
jQuery UI Tutorials Playlist:-
Bootstrap Tutorials Playlist:-
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial
Комментарии