eval Method (Windows Scripting - JScript)
Evaluates JScript code and executes it.
Syntax
eval(codeString)
Arguments
- codeString
Required. A String value that contains valid JScript code.
Remarks
The eval method enables dynamic execution of JScript source code.
The codeString string is parsed by the JScript parser and executed.
The code passed to the eval method is executed in the same context as the call to the eval method.
Whenever possible, use the JSON.parse Method to de-serialize JavaScript Object Notation (JSON) text. The parse method is more secure and executes faster than the eval method.
The following code initializes the variable myDate to a test date.
var dateFn = "Date(1971,3,8)";
var myDate;
eval("myDate = new " + dateFn + ";");
document.write(myDate);
Requirements
Applies To: Global Object (Windows Scripting - JScript)
Change History
Date |
History |
Reason |
---|---|---|
January 2010 |
Modified example. |
Information enhancement. |