Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

eval Method (Visual Studio - JScript)

Evaluates JScript code and executes it.

function eval(codeString : String)

codeString

Required. A string that contains valid JScript code.

The eval function allows dynamic execution of JScript source code.

The code passed to the eval method is executed in the same context as the call to the eval method. Note that new variables or types defined in the eval statement are not visible to the enclosing program.

For example, the following code initializes the variable myDate to a test date.

var dateFn = "Date(1971,3,8)";
var myDate;
eval("myDate = new " + dateFn + ";");

print (myDate);

Community Additions

ADD
Show:
© 2015 Microsoft