JScript Expressions
A JScript expression is a combination of keywords, operators, variables, and literals that yield a value. An expression can perform a calculation, manipulate data, call a function, test data, or perform other operations.
Using Expressions
The simplest expressions are literals. Here are some examples of JScript literal expressions. For more information, see Data in JScript.
3.9 // numeric literal
"Hello!" // string literal
false // Boolean literal
null // literal null value
[1,2,3] // Array literal
var o = {x:1, y:2} // Object literal
var f = function(x){return x*x;} // function literal
Expressions that are more complicated can contain variables, function calls, and other expressions. You can use operators to combine expressions and create complex expressions. Examples of using operators are:
4 + 5 // additon
x += 1 // addition assignment
10 / 2 // division
a & b // bitwise AND
Here are some examples of JScript complex expressions.
radius = 10;
anExpression = 3 * (4 / 5) + 6;
aSecondExpression = Math.PI * radius * radius;
aThirdExpression = "Area is " + aSecondExpression + ".";
myArray = new Array("hello", Math.PI, 42);
myPi = myArray[1];