SQL PHP HTML ASP JavaScript articles and free scripts to download
JavaScript Tutorials
Popular Tutorials
Drop down list
Timer function
JavaScript Tutorials
String
Array
Date & Time
Form Validation
Event Handling
Math Functions
JavaScript Forum
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

 
 

JavaScript if else

If else conditional statement is very common in JavaScript. This logical condition checking is done inside a script as per the requirement. Here is the syntax for if else condition in JavaScript.

If(condition){
Code;
}else{
Code;
}


The first block is executed if the condition is TRUE and second block inside the else condition is executed if the condition is FALSE.

Let us learn one practical example and you can see this in action at confirm window tutorial. Here is the code.

var my_string = confirm("Are you satisfied with the quality of the tutorials here?");
if(my_string){alert("Thank you");
}else{
alert("Please use the contact us page to give your feedbacks");}
Further readings
For Loop with break statement
Do While Loop with break statement in JavaScript
Switch statement
If Else
 
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript