|
| ||||||||||
| Tags: c program, core java, flow control, javascript, statements |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| ||||
| ||||
| What are Flow Control Statements in JavaScript?
![]()
__________________ Blessings to you |
|
#2
| ||||
| ||||
| Re: What are Flow Control Statements in JavaScript?
In JavaScript, you can define variables and manipulate them. A basic execution unit in JavaScript is known as Statement. The following are some basic things that gets applied to the statement :
|
|
#3
| ||||
| ||||
| Re: What are Flow Control Statements in JavaScript?
You can check the following example, so that you can easily understand how to use the Flow Control Statements in JavaScript..!! Here is the code : HTML Code: <html> <head><title>Statements</title></head> <body> <script type="text/javascript"> var a,b,c; a=4, b=16, c=36; a*a; b*b; c*c; { a *= a; b *= b; c *= c; } if (true) document.write("9 statements in total."); </script> </pre> </body> </html> |
|
#4
| ||||
| ||||
| Re: What are Flow Control Statements in JavaScript?
I have provided you with an example of the "if" statements, which is a type of the Statement. The example is little bit long but very easy to understand. Just have a glance on the following example : HTML Code: <html> <head><title>Using the If Statements</title></head> <body> <pre> <script type="text/javascript"> document.write('\n'); var is_december = true; if (is_december) document.write("Merry Christmas!\n"); document.write('\n'); var is_log_on = true; if (is_log_on) { document.write("Open the log file.\n"); document.write("Write the log message.\n"); document.write("Close the log file.\n"); } document.write('\n'); var is_admin = false; if (is_admin) { document.write("Display the edit button.\n"); document.write("Display the add button.\n"); } else { document.write("Display the view button.\n"); } document.write('\n'); var week_day = 4; var open_hours; if (week_day == 0) { open_hours = "closed"; } else if (week_day >= 1 && week_day <= 5) { open_hours = "open from 9:00am to 6:00pm"; } else if (week_day == 6) { open_hours = "open from 9:00am to 4:00pm"; } else { open_hours = "undefined"; } document.write("The library is " + open_hours + ".\n"); </script> </pre> </body> </html> |
|
#5
| ||||
| ||||
| Re: What are Flow Control Statements in JavaScript?
The "switch ... case" statements are also important in the Statements. It is very commonly used when you have to include many conditions at a time. You will get the point better, if you have a look on the following example : HTML Code: <html> <head><title>Examples of Switch Case Statements</title></head> <body> <pre> <script type="text/javascript"> var week_day = 4; var day, open_hours; switch (week_day) { case 0: day = "Sunday"; open_hours = "closed"; break; case 1:...... case 2:...... case 3:..... case 4:..... case 5:..... day = "a weekday"; open_hours = "open from 9:00am to 6:00pm"; break; case 6: day = "unknown"; open_hours = "open from 9:00am to 4:00pm"; break; default: day = "unknown" open_hours = "undefined"; } document.write('\n'); document.write("Today is " + day + ".\n"); document.write("The library is " + open_hours + ".\n"); </script> </pre> </body> </html> |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "What are Flow Control Statements in JavaScript?" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error Control and flow control in TCP/IP? | Diellza | Networking & Security | 5 | 07-01-2011 08:36 AM |
| How to use flow control in ASP 3.0 | Appaji | Software Development | 4 | 06-03-2010 01:59 AM |
| Difference between DML statements and DDL statements | Prashobh Mallu | Software Development | 5 | 11-01-2010 12:07 PM |
| Javascript Control Bar Issue | RAJalias | Software Development | 3 | 25-11-2009 12:31 PM |
| How to Use javascript to control flash files? | Taipai | Software Development | 3 | 15-09-2009 06:43 PM |