Javascript: Working with Boolean

In Javascript, there are two literals true and false corresponding to the boolean true and false respectively. As Javascript is a dynamically typed language, you can declare a boolean variable as follows

var fast = true;

You can use it in if conditions

if (fast) { 
   alert("site is fast");
}  else { 
   alert ("site is slow");
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s