Site hosted by Angelfire.com: Build your free website today!
JavaScript
Another Vrong © JavaScript Tutorial

JavaScript Statements

JavaScript also includes built-in statements, which allow you to do things like set up loops in your program. One of the most important statements is the function statement, which is the keyword you will use to create JavaScript functions - a set of procedures that performs a specific task. Once defined, a function can be called anywhere within a script. Most of the remaining JavaScript statements are used to build branches or loops in your JavaScript programs. Some of the most commonly used statements include

* var
the var statement declares a variable name with its given value, for instance, var a = 1.

* if ... else
This is a conditional statement that executes one set of statements if a condition is true and a second set of statements if a condition is false.


var x=0
if (x==1){
document.write("x=1") }
else {
document.write("x does not equal 1") }


The output for this script would be

x does not equal 1


* for
The for statement is used to build loops. A typical application of a for loop is a counter, like:


for (var i = 0; i < 10; I++){
document.write(i) }


The output for this script would be
0123456789

Under Construction ... more to come ...



while
break
continue
return
with


[JavaScript History] [What is JavaScript] [Using JavaScript] [JavaScript Language] [JavaScript Statements]
[JavaScript Object Model] [JavaScript Event Handler] [JavaScript Example] [JavaScript Home]
Comments & Suggestions or Send Feedback
Internet Addiction, Funny Stuff & Cricket .