Home | | Web Technology | Conditional Statements

Chapter: Web Technology : JavaScript (JS)

Conditional Statements

Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this.

Conditional Statements

 

Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this.

In JavaScript we have the following conditional statements:

 

if statement - use this statement if you want to execute some code only if a specified condition is true

 

if...else statement - use this statement if you want to execute some code if the condition is true and another code if the condition is false

 

if...else if....else statement - use this statement if you want to select one of many blocks of code to be executed

 

switch statement - use this statement if you want to select one of many blocks of code to be executed

 

If Statement

 

You should use the if statement if you want to execute some code only if a specified condition is true.

 

Syntax

if (condition)

{

 

code to be executed if condition is true

 

}

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Web Technology : JavaScript (JS) : Conditional Statements |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.