How to use eval function in js
This article mainly introduces how to use the eval function in js, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand it.
The eval () function evaluates the JavaScript string and executes it as script code. If the parameter is an expression, the eval () function executes the expression. If the argument is a Javascript statement, eval () executes the Javascript statement.
Grammar
Eval (string)
Parameters:
● string: required. The string to evaluate that contains the JavaScript expression to evaluate or the statement to execute.
Description: all major browsers support the eval () function
Example:
Eval ("Xerox 10, politics 20, console.log (Xeroy)"); console.log (eval ("2x2")); console.log (eval ("Xerox 17"))
Output:
200427 Thank you for reading this article carefully. I hope the article "how to use the eval function in js" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!