English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
JavaScript Global Properties/Function
eval()The function calculates or executes JavaScript code represented as a string.
If the string represents an expression, eval() will evaluate the expression.
If the parameter represents one or more JavaScript statements, the eval() function will execute these statements.
If the parameter of eval() is not a string, the parameter returned by eval() remains unchanged.
eval(string)
var x = 20; var y = 10; var a = eval('x * y'); var b = eval('2 + 2'); var c = eval('x + 15'); var res = a + '<br>' + b + '<br>' + c;Test and See‹/›
All browsers fully support the eval() function:
Function | |||||
eval() | Is | Is | Is | Is | Is |
Parameter | Description |
---|---|
string | A string representing a JavaScript expression, statement, or sequence of statements. |
Return Value: | The completion value of the given code. If the completion value is empty, it returns undefined. |
---|---|
JavaScript Version: | ECMAScript 1 |