Home  >  Article  >  Web Front-end  >  What does eval mean in js

What does eval mean in js

little bottle
little bottleOriginal
2019-05-31 15:29:314030browse

What does eval mean in js

Definition and usage: The

eval() function can calculate a string and execute the JavaScript code in it.

Syntax:

eval(string)

Parameter string:

Required. A string to evaluate, containing a JavaScript expression to evaluate or a statement to execute.

Return value:

The value obtained by calculating string (if any).

Note:

This method only accepts original strings as parameters. If the string parameter is not an original string, then the method will return without any changes.

So please do not pass String objects as parameters to the eval() function. ECMAScript implementations allow an EvalError exception to be thrown if an attempt is made to override the eval property or assign the eval() method to another property and call it through that property.

Exception:

If there are no legal expressions and statements in the parameters, a SyntaxError exception is thrown. If eval() is called illegally, an EvalError exception is thrown. If the Javascript code passed to eval() generates an exception, eval() will pass the exception to the caller.

The above is the detailed content of What does eval mean in js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is js classNext article:What is js class