<!doctypehtml><html lang=en-US><title>
   JavaScript - Switch Case
  </title><meta charset=utf-8><meta content="JavaScript - Switch Case,  You can use multiple if...elseâ¦if statements, as in the previous chapter, to perform a multiway branch. However, this is not always the best solution, espe"name=description><meta content="C, C++, Python, Java, HTML, CSS, JavaScript, SQL, PHP, jQuery, XML, DOM, Bootstrap, Tutorials, Articles, Programming, training, learning, quiz, preferences, examples, code"name=keywords><link href=https://www.tutorialspoint.com/javascript/javascript_switch_case.htm rel=canonical><link rel="shortcut icon"href=/favicon.ico type=image/x-icon><meta content=width=device-width,initial-scale=1.0,user-scalable=yes name=viewport><link href=/themes/css/style-min-v1.css?v=4.62 rel=stylesheet><script src=/themes/js/prism-core.min.js></script><script src=/themes/js/prism-autoloader.min.js></script><script src=/themes/js/script-min-v1.js?v=3.0.2040254></script><script>function printPage() { window.print(); }
function readCookie(name) {
     var nameEQ = name + "=";
     var ca = document.cookie.split(';');
     for (var i = 0; i < ca.length; i++) {
          var c = ca[i];
          while (c.charAt(0) == ' ') c = c.substring(1, c.length);
          if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
     }
     return null;
     }</script><script data-cfasync=false id=adp1>(function(w, d) { var s = d.createElement('script'); s.src = '//cdn.adpushup.com/40046/adpushup.js'; s.type = 'text/javascript'; s.async = true; (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); })(window, document);</script><script data-cfasync=false id=adp2>(function(w, d) {var cval = readCookie('subscription_purchased');if(cval == '1'){ return; } var s = d.createElement('script'); s.src = '//delivery.adrecover.com/18107/adRecover.js'; s.type = 'text/javascript'; s.async = true; (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); })(window, document);</script><style>.butnn-save a{color:#fff;} .notes_msg{color:green; margin-left:20px; margin-top:15px;}
.right-menu .mui-btn {
    background-color:#f8ba24;
}
a.demo {
    background:#f8ba24;
}
li.heading {
    background:#f8ba24;
}
.course-box{background:#f8ba24}
.home-intro-sub p{color:#f8ba24}
a.demo{
   top: 12px;
   float:right;
}
.prettyprint{
   width: 99%;
}</style><body><header id=header><div class="pop-modal overlay-pop popdiv"><div class="modal-window small"><span class=close title=close> × </span><div class=pop-content></div><span class=msg> </span></div></div><div class=wrap_loader><div class=imgLoader></div></div><input id=vu name=vu type=hidden><div class="mui-appbar mui-container-fulid top-menu"><div class=mui-container><div class="top-menu-item home"><a title="TutorialsPoint - Home"href=https://www.tutorialspoint.com/index.htm target=_blank> <i class="fal fa-home"> </i> <span> Home </span> </a></div><div class="top-menu-item qa"><a title="Job @ Tutorials Point"href=https://www.tutorialspoint.com/about/about_careers.htm target=_blank> <i class="fa fa-suitcase"> </i> <span> Jobs </span> </a></div><div class="top-menu-item tools"><a title="Tools - Online Development and Testing Tools"href=https://www.tutorialspoint.com/online_dev_tools.htm target=_blank> <i class="fal fa-cogs"> </i> <span> Tools </span> </a></div><div class="top-menu-item coding-ground"><a title="Coding Ground - Free Online IDE and Terminal"href=https://www.tutorialspoint.com/codingground.htm target=_blank> <i class="fal fa-code"> </i> <span> Coding Ground </span> </a></div><div class="top-menu-item current-affairs"><a title="Daily Current Affairs"href=https://www.tutorialspoint.com/current_affairs.htm target=_blank> <i class="fal fa-layer-plus"> </i> <span> Current Affairs </span> </a></div><div class="top-menu-item upsc-notes"><a title="UPSC IAS Exams Notes - TutorialsPoint"href=https://www.tutorialspoint.com/upsc_ias_exams.htm target=_blank> <i class="fal fa-user-tie"> </i> <span> UPSC Notes </span> </a></div><div class="top-menu-item articles"><a title="Top Online Tutors - Tutor Connect"href=https://www.tutorialspoint.com/tutor_connect/index.php target=_blank> <i class="fal fa-user"> </i> <span> Online Tutors </span> </a></div><div class="top-menu-item whiteboard"><a title="Free Online Whiteboard"href=https://www.tutorialspoint.com/whiteboard.htm target=_blank> <i class="fal fa-chalkboard"> </i> <span> Whiteboard </span> </a></div><div class="top-menu-item articles"><a title="Tutorx - The Best Learning App"href=https://www.tutorix.com rel=nofollow target=_blank> <i class="fal fa-video"> </i> <span> Tutorix </span> </a></div><div class="top-menu-item net-meeting"><a title="Login TutorialsPoint"href=https://www.tutorialspoint.com/market/login.jsp?v=1.3 target=_blank> <i class="fal fa-sign-in-alt"> </i> <span> Login </span> </a></div><div class=social-menu-item><a title="tutorialspoint @ Facebook"data-placement=bottom href=https://www.facebook.com/tutorialspointindia rel=nofollow target=_blank> <i class="fab fa-facebook-f"> </i> </a><a title="tutorialspoint @ Twitter"data-placement=bottom href=https://www.twitter.com/tutorialspoint rel=nofollow target=_blank> <i class="fab fa-twitter"> </i> </a><a title="tutorialspoint @ Linkedin"data-placement=bottom href=https://www.linkedin.com/company/tutorialspoint rel=nofollow target=_blank> <i class="fab fa-linkedin-in"> </i> </a><a title="tutorialspoint YouTube"data-placement=bottom href=https://www.youtube.com/channel/UCVLbzhxVTiTLiVKeGV7WEBg rel=nofollow target=_blank> <i class="fab fa-youtube"> </i> </a></div></div></div><div class="mui-appbar mui-container-fulid mui--appbar-line-height mui--z1"id=logo-menu><div class=mui-container><div class=left-menu><a href=https://www.tutorialspoint.com/index.htm title=Tutorialspoint> <img alt=tutorialspoint class=tp-logo src=/javascript/images/logo.png> </a><div class=mui-dropdown><a class="mui-btn mui-btn--primary categories"data-mui-toggle=dropdown> <i class="fa fa-th-large"> </i> <span> Categories <span class=mui-caret> </span> </span> </a><ul class="mui-dropdown__menu cat-menu"><li><ul><li><a href=/academic_tutorials.htm> <i class="fa fa-caret-right"> </i> Academic Tutorials </a><li><a href=/big_data_tutorials.htm> <i class="fa fa-caret-right"> </i> Big Data & Analytics </a><li><a href=/computer_programming_tutorials.htm> <i class="fa fa-caret-right"> </i> Computer Programming </a><li><a href=/computer_science_tutorials.htm> <i class="fa fa-caret-right"> </i> Computer Science </a><li><a href=/database_tutorials.htm> <i class="fa fa-caret-right"> </i> Databases </a><li><a href=/devops_tutorials.htm> <i class="fa fa-caret-right"> </i> DevOps </a><li><a href=/digital_marketing_tutorials.htm> <i class="fa fa-caret-right"> </i> Digital Marketing </a><li><a href=/engineering_tutorials.htm> <i class="fa fa-caret-right"> </i> Engineering Tutorials </a><li><a href=/upsc_ias_exams.htm> <i class="fa fa-caret-right"> </i> Exams Syllabus </a><li><a href=/famous_monuments.htm> <i class="fa fa-caret-right"> </i> Famous Monuments </a><li><a href=/gate_exams_tutorials.htm> <i class="fa fa-caret-right"> </i> GATE Exams Tutorials </a><li><a href=/latest_technologies.htm> <i class="fa fa-caret-right"> </i> Latest Technologies </a><li><a href=/machine_learning_tutorials.htm> <i class="fa fa-caret-right"> </i> Machine Learning </a><li><a href=/mainframe_tutorials.htm> <i class="fa fa-caret-right"> </i> Mainframe Development </a><li><a href=/management_tutorials.htm> <i class="fa fa-caret-right"> </i> Management Tutorials </a><li><a href=/maths_tutorials.htm> <i class="fa fa-caret-right"> </i> Mathematics Tutorials </a><li><a href=/microsoft_technologies_tutorials.htm> <i class="fa fa-caret-right"> </i> Microsoft Technologies </a><li><a href=/misc_tutorials.htm> <i class="fa fa-caret-right"> </i> Misc tutorials </a><li><a href=/mobile_development_tutorials.htm> <i class="fa fa-caret-right"> </i> Mobile Development </a><li><a href=/java_technology_tutorials.htm> <i class="fa fa-caret-right"> </i> Java Technologies </a><li><a href=/python_technologies_tutorials.htm> <i class="fa fa-caret-right"> </i> Python Technologies </a><li><a href=/sap_tutorials.htm> <i class="fa fa-caret-right"> </i> SAP Tutorials </a><li><a href=/scripting_lnaguage_tutorials.htm> <i class="fa fa-caret-right"> </i> Programming Scripts </a><li><a href=/selected_reading.htm> <i class="fa fa-caret-right"> </i> Selected Reading </a><li><a href=/software_quality_tutorials.htm> <i class="fa fa-caret-right"> </i> Software Quality </a><li><a href=/soft_skill_tutorials.htm> <i class="fa fa-caret-right"> </i> Soft Skills </a><li><a href=/telecom_tutorials.htm> <i class="fa fa-caret-right"> </i> Telecom Tutorials </a><li><a href=/upsc_ias_exams.htm> <i class="fa fa-caret-right"> </i> UPSC IAS Exams </a><li><a href=/web_development_tutorials.htm> <i class="fa fa-caret-right"> </i> Web Development </a><li><a href=/sports_tutorials.htm> <i class="fa fa-caret-right"> </i> Sports Tutorials </a><li><a href=/xml_technologies_tutorials.htm> <i class="fa fa-caret-right"> </i> XML Technologies </a><li><a href=/multi_language_tutorials.htm> <i class="fa fa-caret-right"> </i> Multi-Language </a><li><a href=/questions_and_answers.htm> <i class="fa fa-caret-right"> </i> Interview Questions </a></ul></ul><div class=clear></div></div></div><div class=right-menu><div class=toc-toggle><a href=javascript:void(0);> <i class="fa fa-bars"> </i> </a></div><div class=mobile-search-btn><a href=https://www.tutorialspoint.com/index.htm> <i class="fal fa-search"> </i> </a></div><div class=search-box-wrap><div class=search-box><div><input placeholder="Search latest courses, ebooks and prime packs..."autocomplete=off class=input id=search-strings name=key><button id=btnSearch><i class="fa fa-search"title=Search> </i></button></div></div><div class=search-box id=search-results></div><div class=clear></div><script>$('#search-strings').keyup(function () {
			var keyword = $('#search-strings').val();
			if (keyword != "" && keyword.length > 2) {
				$.ajax({
					url:"https://search.tutorialspoint.com/market_urls_suggestion.php",
					method: "POST",
               type: 'POST',
					dataType: "json",
               cache:false,
					data: {
						'keyword': keyword
					},
					error: function (err) {
						console.log ( err );
					},
					success: function (data) {
						if (data.length > 0) {
					//var str = '<div class="search_title arrow_search">Search Results</div><ul>';
					var str = '<div class="search-overlay"><ul>';
					data.forEach((item) => {
					   var iconStr = '<i class="fa fa-play-circle"></i>';
					   if(item.type=='E'){
						  iconStr = '<i class="fa fa-file-pdf"></i>';
					   }
					   if(item.type=='B'){
						  iconStr = '<i class="fa fa-cubes"></i>';
					   }
					   if(item.type=='A' || item.type=='I' || item.type=='P'){ // profile/author/instructor
						  iconStr = '<i class="fa fa-user"></i>';
					   }
					   str = str + '<a href="'+item.url+'" target="_blank"><li class="clsHeadQuestion">'+iconStr+' '+item.name+'</li></a>'; 
					});
					str = str + '</ul><br/></div><div class="clear"></div>';
							$('#search-results').show();
							$('#search-results').html(str);
						} else {
							$('#search-results').hide();
							$('#search-results').html('');
						}
					}
				});
			}else{
				$('#search-results').hide();
				$('#search-results').html('');
			}
		});
	 $('#btnSearch').click(function(){
		   var keyword = $('#search-strings').val();
		   window.location.href = "https://www.tutorialspoint.com/search/"+keyword;
	 });
	 $(document).mouseup(function(e) 
	 {
		 var container = $('#search-results');            
		 if (!container.is(e.target) && container.has(e.target).length === 0) 
		 {
			 container.hide();
		 }
	 });</script></div><div class="menu-btn videos-btn"><a href=https://www.tutorialspoint.com/questions/index.php> <i class="fa fa-location-arrow"> </i> <span> Q/A </span> </a></div><div class="menu-btn library-btn"><a href=https://www.tutorialspoint.com/tutorialslibrary.htm> <i class="fa fa-books"> </i> <span> Library </span> </a></div><div class="menu-btn ebooks-btn"><a href=https://www.tutorialspoint.com/ebooks> <i class="fa fa-book-reader"> </i> <span> eBooks </span> </a></div><div class="menu-btn videos-btn"><a href=https://www.tutorialspoint.com/market/index.php> <i class="fa fa-video"> </i> <span> Courses </span> </a></div></div></div></div></header><div class="mui-container-fluid content"><div class=mui-container><div class="mui-col-md-3 tutorial-toc"><div class=mini-logo><img alt="Javascript Tutorial"src=/javascript/images/javascript-mini-logo.jpg></div><ul class="toc chapters"><li><a class=videolink href=/javascript_online_training/index.asp target=_blank> <img alt="JavaScript Video Tutorials"src=/javascript/images/javascript-video-tutorials.jpg> </a></ul><ul class="toc chapters"><li class=heading>Javascript Basics Tutorial<li><a href=/javascript/index.htm> Javascript - Home </a><li><a href=/javascript/javascript_overview.htm> Javascript - Overview </a><li><a href=/javascript/javascript_syntax.htm> Javascript - Syntax </a><li><a href=/javascript/javascript_enabling.htm> Javascript - Enabling </a><li><a href=/javascript/javascript_placement.htm> Javascript - Placement </a><li><a href=/javascript/javascript_variables.htm> Javascript - Variables </a><li><a href=/javascript/javascript_operators.htm> Javascript - Operators </a><li><a href=/javascript/javascript_ifelse.htm> Javascript - If...Else </a><li><a href=/javascript/javascript_switch_case.htm> Javascript - Switch Case </a><li><a href=/javascript/javascript_while_loop.htm> Javascript - While Loop </a><li><a href=/javascript/javascript_for_loop.htm> Javascript - For Loop </a><li><a href=/javascript/javascript_forin_loop.htm> Javascript - For...in </a><li><a href=/javascript/javascript_loop_control.htm> Javascript - Loop Control </a><li><a href=/javascript/javascript_functions.htm> Javascript - Functions </a><li><a href=/javascript/javascript_events.htm> Javascript - Events </a><li><a href=/javascript/javascript_cookies.htm> Javascript - Cookies </a><li><a href=/javascript/javascript_page_redirect.htm> Javascript - Page Redirect </a><li><a href=/javascript/javascript_dialog_boxes.htm> Javascript - Dialog Boxes </a><li><a href=/javascript/javascript_void_keyword.htm> Javascript - Void Keyword </a><li><a href=/javascript/javascript_page_printing.htm> Javascript - Page Printing </a></ul><ul class="toc chapters"><li class=heading>JavaScript Objects<li><a href=/javascript/javascript_objects.htm> Javascript - Objects </a><li><a href=/javascript/javascript_number_object.htm> Javascript - Number </a><li><a href=/javascript/javascript_boolean_object.htm> Javascript - Boolean </a><li><a href=/javascript/javascript_strings_object.htm> Javascript - Strings </a><li><a href=/javascript/javascript_arrays_object.htm> Javascript - Arrays </a><li><a href=/javascript/javascript_date_object.htm> Javascript - Date </a><li><a href=/javascript/javascript_math_object.htm> Javascript - Math </a><li><a href=/javascript/javascript_regexp_object.htm> Javascript - RegExp </a><li><a href=/javascript/javascript_html_dom.htm> Javascript - HTML DOM </a></ul><ul class="toc chapters"><li class=heading>JavaScript Advanced<li><a href=/javascript/javascript_error_handling.htm> Javascript - Error Handling </a><li><a href=/javascript/javascript_form_validations.htm> Javascript - Validations </a><li><a href=/javascript/javascript_animation.htm> Javascript - Animation </a><li><a href=/javascript/javascript_multimedia.htm> Javascript - Multimedia </a><li><a href=/javascript/javascript_debugging.htm> Javascript - Debugging </a><li><a href=/javascript/javascript_image_map.htm> Javascript - Image Map </a><li><a href=/javascript/javascript_browsers_handling.htm> Javascript - Browsers </a></ul><ul class="toc chapters"><li class=heading>JavaScript Useful Resources<li><a href=/javascript/javascript_questions_answers.htm> Javascript - Questions And Answers </a><li><a href=/javascript/javascript_quick_guide.htm> Javascript - Quick Guide </a><li><a href=/javascript/javascript_builtin_functions.htm> Javascript - Functions </a><li><a href=/javascript/javascript_useful_resources.htm> Javascript - Resources </a></ul><ul class="toc reading"><li class=sreading>Selected Reading<li><a href=/upsc_ias_exams.htm target=_top> UPSC IAS Exams Notes </a><li><a href=/developers_best_practices/index.htm target=_top> Developer's Best Practices </a><li><a href=/questions_and_answers.htm target=_top> Questions and Answers </a><li><a href=/effective_resume_writing.htm target=_top> Effective Resume Writing </a><li><a href=/hr_interview_questions/index.htm target=_top> HR Interview Questions </a><li><a href=/computer_glossary.htm target=_top> Computer Glossary </a><li><a href=/computer_whoiswho.htm target=_top> Who is Who </a></ul><div id=stickyparent><div id=sticky-ad style=height:250px;width:300px;><div class=_ap_apex_ad id=430c9911-782f-495d-88f9-69f58ca8c9a4><script>var adpushup = adpushup || {};
adpushup.que = adpushup.que || [];
adpushup.que.push(function() {
adpushup.triggerAd("430c9911-782f-495d-88f9-69f58ca8c9a4");
});</script></div></div></div></div><div class="mui-col-md-6 tutorial-content"><h1>JavaScript - Switch Case</h1><hr><div id=google-top-ads><div class=top-ad-heading>Advertisements</div><div class=google-top-ads style=text-align:center><div id=adp_top_ads style=text-align:center!important;min-height:90px!important></div><script>var adPos = document.getElementById('adp_top_ads');
     var ad_id_720 = "8014640d-fd34-4b2e-9b1b-cc67234a2325";
     var ad_id_650 = "2d1bb2c4-eb72-471d-9c80-1bf5514728c1";
     var ad_id_300 = "df94a1a9-ae2f-432d-9a92-d93823ff4503";
     var width = window.innerWidth;
     var ad_id = ad_id_720;
     if( width <= 768 ){
        ad_id =  ad_id_300;
     }else if( width <= 1435 ){
        ad_id =  ad_id_650;
     }
     adPos.innerHTML = '<div id="' + ad_id + '" class="_ap_apex_ad"></div>';
     var adpushup = adpushup || {};
     adpushup.que = adpushup.que || [];
     adpushup.que.push(function() {
     adpushup.triggerAd(ad_id);
     });</script></div></div><br><div class="mui-container-fluid button-borders"><div class=pre-btn><a href=/javascript/javascript_ifelse.htm> <i class="fal fa-chevron-circle-left"> </i> Previous Page </a></div><div class=nxt-btn><a href=/javascript/javascript_while_loop.htm> Next Page <i class="fal fa-chevron-circle-right"> </i>   </a></div></div><div class=clearer></div><p>You can use multiple <b> if...else…if </b> statements, as in the previous chapter, to perform a multiway branch. However, this is not always the best solution, especially when all of the branches depend on the value of a single variable.<p>Starting with JavaScript 1.2, you can use a <b> switch </b> statement which handles exactly this situation, and it does so more efficiently than repeated <b> if...else if </b> statements.<h2>Flow Chart</h2><p>The following flow chart explains a switch-case statement works.</p><img alt="Switch case"src=/javascript/images/switch_case.jpg><h3>Syntax</h3><p>The objective of a <b> switch </b> statement is to give an expression to evaluate and several different statements to execute based on the value of the expression. The interpreter checks each <b> case </b> against the value of the expression until a match is found. If nothing matches, a <b> default </b> condition will be used.<pre class="result notranslate">switch (expression) {
   case condition 1: statement(s)
   break;
   
   case condition 2: statement(s)
   break;
   ...
   
   case condition n: statement(s)
   break;
   
   default: statement(s)
}
</pre><p>The <b> break </b> statements indicate the end of a particular case. If they were omitted, the interpreter would continue executing each statement in each of the following cases.<p>We will explain <b> break </b> statement in <b> Loop Control </b> chapter.<h3>Example</h3><p>Try the following example to implement switch-case statement.<div class=demo-view><a class=demo href=http://tpcg.io/pNWbNd rel=nofollow target=_blank> <i class=fa-external-link> </i> Live Demo </a></div><pre class="prettyprint notranslate">&LThtml>
   &LTbody>   
      &LTscript type = "text/javascript">
         &LT!--
            var grade = 'A';
            document.write("Entering switch block&LTbr />");
            switch (grade) {
               case 'A': document.write("Good job&LTbr />");
               break;
            
               case 'B': document.write("Pretty good&LTbr />");
               break;
            
               case 'C': document.write("Passed&LTbr />");
               break;
            
               case 'D': document.write("Not so good&LTbr />");
               break;
            
               case 'F': document.write("Failed&LTbr />");
               break;
            
               default:  document.write("Unknown grade&LTbr />")
            }
            document.write("Exiting switch block");
         //-->
      &LT/script>      
      &LTp>Set the variable to different value and then try...&LT/p>
   &LT/body>
&LT/html>
</pre><h3>Output</h3><pre class="result notranslate">Entering switch block
Good job
Exiting switch block
Set the variable to different value and then try...
</pre><p>Break statements play a major role in switch-case statements. Try the following code that uses switch-case statement without any break statement.<div class=demo-view><a class=demo href=http://tpcg.io/ouqbd3 rel=nofollow target=_blank> <i class=fa-external-link> </i> Live Demo </a></div><pre class="prettyprint notranslate">&LThtml>
   &LTbody>      
      &LTscript type = "text/javascript">
         &LT!--
            var grade = 'A';
            document.write("Entering switch block&LTbr />");
            switch (grade) {
               case 'A': document.write("Good job&LTbr />");
               case 'B': document.write("Pretty good&LTbr />");
               case 'C': document.write("Passed&LTbr />");
               case 'D': document.write("Not so good&LTbr />");
               case 'F': document.write("Failed&LTbr />");
               default: document.write("Unknown grade&LTbr />")
            }
            document.write("Exiting switch block");
         //-->
      &LT/script>      
      &LTp>Set the variable to different value and then try...&LT/p>
   &LT/body>
&LT/html>
</pre><h3>Output</h3><pre class="result notranslate">Entering switch block
Good job
Pretty good
Passed
Not so good
Failed
Unknown grade
Exiting switch block
Set the variable to different value and then try...
</pre><div class="mui-container-fluid button-borders show"id=bottom_navigation><div class=pre-btn><a href=/javascript/javascript_ifelse.htm> <i class="fal fa-chevron-circle-left"> </i> Previous Page </a><a class=hide-on-mobile href=javascript:printPage();> <i class="fa fa-print"> </i> Print Page </a></div><div class=nxt-btn><a href=/javascript/javascript_while_loop.htm> Next Page <i class="fal fa-chevron-circle-right"> </i>   </a></div></div><div class=space-bottom style=margin-bottom:20px;></div><div class=google-bottom-ads id=google-bottom-ads><div>Advertisements</div><div><div id=adp_bottom_ads></div><script>var adPos = document.getElementById('adp_bottom_ads');
var mobile_ad_id = "a8a632a6-046e-4f5c-b25f-8bc82ac89fb2";
var desktop_ad_id = "e7ddd6f7-1ab0-494a-bade-887daa4373a0";
desktop_ad_id = "4951d1d6-24d4-4a31-afb7-2c22c489eae1";
var adpushup = adpushup || {};
adpushup.que = adpushup.que || [];
adpushup.que.push(function() {
var ad_id = window.innerWidth <= 768 ? mobile_ad_id : desktop_ad_id;
adPos.innerHTML = '<div id="' + ad_id + '" class="_ap_apex_ad"></div>';
adpushup.triggerAd(ad_id);
});</script></div><div class=space-bottom></div></div></div><div class="mui-col-md-2 google-right-ads"style="display: none;"id=chapter-menu><input id=vu name=vu type=hidden><div class=space-top></div><div class=mui-panel><ul class=paid-menu id=div-right-menu><li><a title="Print this page"class=hide-on-mobile href=javascript:printPage();> <i class="fa fa-print"> </i> Print </a><li><a title="Add Custom Notes"class=add_notes href=javascript:void(0) onclick=add_notes();> <i class="fa fa-edit"> </i>  Add Notes </a><li><a class="clsPage text-bookmark"title="Add Bookmark"href=javascript:void(0) id=text-bookmark onclick=text_bookmark()> <i class="fal fa-bookmark"> </i>  Bookmark this page </a><li><a title="Report Error"href=javascript:void(0); id=report_error_popup onclick=report_error_popup();> <i class="fal fa-bell"> </i>  Report Error </a><li><a title="Give Suggestions"href=javascript:void(0); id=suggestion_popup onclick=suggestion_popup();> <i class="fal fa-badge-check"> </i>  Suggestions </a></ul><br><div class="error_msg display_msg"style=color:red;text-align:left;></div><div class="success_msg display_msg"style=color:green;text-align:left;></div><div class=profile-my-notes id=text_notes_div style=display:none;><textarea placeholder="Enter your custom notes..."class=text_notes id=text_notes name=text_notes rows=10></textarea><br><a class=butn-save href=javascript:void(0); id=submit_text_notes onclick=submit_text_notes();> Save </a><a class="pop-no butn-cancel"href=javascript:void(0); onclick=notesClose();> Close </a><p class=notes_msg></div><div class=bottom-menu><button class=tp-btn><i class="fal fa-box-up"> </i> <a href=https://www.tutorialspoint.com/market/student/dashboard.jsp> Dashboard </a></button><button class=tp-btn id=btnLogout><i class="fal fa-sign-out-alt"> </i> <a href=javascript:void(0)> Logout </a></button></div></div></div><div class="mui-col-md-2 google-right-ads"id=google-right-ads><div class=space-top></div><div style="margin: 0px auto !important;margin-top:5px;min-height:250px!important"class=google-right-ad><div class=_ap_apex_ad id=f0f6cff6-393d-4170-b63a-d9ff06ca9f25><script>if( window.innerWidth > 768 ){
   var adpushup = adpushup || {};
   adpushup.que = adpushup.que || [];
   adpushup.que.push(function() {
   adpushup.triggerAd("f0f6cff6-393d-4170-b63a-d9ff06ca9f25");
   });
}</script></div></div><div class=google-right-ad style=margin-top:16px;min-height:250px!important><div class=_ap_apex_ad id=5c0affd5-724a-475c-bfcd-cecbc7660c36><script>if( window.innerWidth > 768 ){
   var adpushup = adpushup || {};
   adpushup.que = adpushup.que || [];
   adpushup.que.push(function() {
   adpushup.triggerAd("5c0affd5-724a-475c-bfcd-cecbc7660c36");
   });
}</script></div></div><div class=google-right-ad style=margin-top:16px;margin-bottom:15px;min-height:600px!important><div class=_ap_apex_ad id=8f8814c2-d64c-4d26-9cb9-543653c0b48f><script>if( window.innerWidth > 768 ){
   var adpushup = adpushup || {};
   adpushup.que = adpushup.que || [];
   adpushup.que.push(function() {
   adpushup.triggerAd("8f8814c2-d64c-4d26-9cb9-543653c0b48f");
   });
}</script></div></div><div class=space-bottom style=margin-bottom:15px;></div></div></div></div><div class=clear></div><footer id=footer><div class=mui--text-center><div class="mui--text-caption mui--text-light"><a class=logo href=/index.htm> <img alt="Tutorials Point"title="Tutorials Point"class=img-responsive src=/images/logo-black.png> </a></div><ul class="mui-list--inline mui--text-body2 mui--text-light"><li><a href=/about/index.htm> <i class="fal fa-globe"> </i> About us </a><li><a href=/about/return_refund_policy.htm> <i class="fal fa-asterisk"> </i> Refund Policy </a><li><a href=/about/about_terms_of_use.htm> <i class="fal fa-asterisk"> </i> Terms of use </a><li><a href=/about/about_privacy.htm> <i class="fal fa-shield-check"> </i> Privacy Policy </a><li><a href=/about/faq.htm> <i class="fal fa-question-circle"> </i> FAQ's </a><li><a href=/about/contact_us.htm> <i class="fal fa-map-marker-alt"> </i> Contact </a></ul><div class="mui--text-caption mui--text-light bottom-copyright-text">© Copyright 2021. All Rights Reserved.</div></div><script async src=https://www.googletagmanager.com/gtag/js?id=UA-232293-6></script><script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-232293-6');</script><script src=https://www.tutorialspoint.com/market/public/assets/js/text_menu.js?v=2.11></script><script>$(document).ready(function (){
    var cval = readCookie('subscription_purchased');
    if(cval == '1'){
          // logged in and purchased subscription.
          $('#google-right-ads').remove();
          $('#adp1').remove();
          $('#adp2').remove();
          $('#stickyparent').remove();
          $('#google-top-ads').remove();
          $('#adp_top_ads').remove();
          $('#google-bottom-ads').remove();
          $('.tutorial-content hr').remove();
          $('.login').remove();
          $('#chapter-menu').show();
          $('.content h1').css("border-bottom", "none");
          $('.google-right-ads').css("padding-right", "0px");
          $('.tutorial-content').css("border-radius", "10px");
          $('#chapter-menu .mui-panel').css("border-radius", "10px");
     }
     $(document).on("click", "#btnLogout", function(){
       $.ajax({
           type: 'GET',
           dataType: 'JSON',
           cache: false,
           url: "https://www.tutorialspoint.com/market/logout.jsp",
           complete: function (xhr, statusText) {
               if(xhr.status == 200) {
                   window.location.href = 'https://www.tutorialspoint.com/index.htm'
               } else {
                   console.log("something went wrong");
               }
           }
       });
    });
});</script></footer>