If Statements

Control structures and statements are essential in order to control the flow of your programs. You can control to carry out different operation in different circumstances.

There are three forms of if statement in JavaScript.

1. if Statement 2. if...else statement 3. if...else if... statement
1. if statement

The if statement allows JavaScript to make decisions and execute statements conditionally.

Syntax
if ( < condition > ) { 
    <sequence of statement > ;
}
2. if...else statement

The 'if...else' statement allows JavaScript to execute statements in a more controlled way.

Syntax
if(<condition>) {
	<sequence of statement 1>;
}
else {
	<sequence of statement 2>;
}
3. if...else if... statement

It is an advanced form of if…else that allows JavaScript to make a correct decision out of several conditions.

if(<condition 1>)
{
	<sequence of statement 1>;
}
else if(<condition 2>)
{
	<sequence of statement 2>;
}
else(<condition 3>)
{
	<sequence of statement 3>;
}
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +