Thursday, February 09, 2006

JavaScript Statements & Expressions

Statements-

A small collection of commands including if, while, and for which are combined with objects, properties, methods, and events to round out the JavaScript language. These statements work independently from any object so you can use them whenever you want to. JavaScript provides the bare essential statements to produce a fully functional application. The eleven statements that JavaScript provides are as follows: // comment, break, continue, for, for…in, function, if…else, new, return, var, while, with. It does not implement the switch statement like Java does but it may in the future.

http://www.javaworld.com/jw-12-1996/jw-12-javascript.html

Expressions-

An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value. The value may be a number, a string, or a logical value. There are two types of expressions: assignment operators (assign a value to a variable) and plain operators (simply have a value). JavaScript uses the following expressions: Arithmetic- evaluates to a number (modulus, increment, decrement…), String- evaluates to a character string, for example "Fred" or "234", Logical- evaluates to true or false (and(&&), or(), not(!)) . When creating a variable you have to assign it a value or it is referred to as undefined and will produce a run time error. Using the keyword null can help assign a value to empty variables. JavaScript also implements a conditional operator which assigns one of two values according to a condition that has to be met or not met.

0 Comments:

Post a Comment

<< Home