JScript Language Elements

| Tutorial | Reference |

Expressions and Eval()
The term "expression", in JScript, refers to a string that a human being would read as a Boolean or mathematical expression. (Expressions contain symbol characters like "+" rather than words like "added to".)

EXAMPLES:
var oneExpression = "3 * (4 / 5)";
var aSecondExpression = "Math.PI * radius * 2";
var aThirdExpression = aSecondExpression + "%" + oneExpression;
var aFourthExpression = "(" + aSecondExpression + ") % (" + oneExpression + ")";
Eval() is a special function that evaluates any legitimate JScript expression and returns the result.

EXAMPLES:
var anExpression = "6 * 9 % 7";
var total = eval(anExpression);        //  Assigns the value 5 to the variable total.
var anotherExpression = "6 * (9 % 7)";
total = eval(anotherExpression)        //  Assigns the value 12 to the variable total.

var totality = eval("...surrounded by acres of clams.");        // Generates an error.



© 1996 by Microsoft Corporation.