Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use eval function in js

Shulou Source: shulou.com Published: 2022-06-02 08:24:48 10月03日 Update

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!

Tags: Functions articles parameters expressions statements characters strings support code value interests at the same time more friends browsers knowledge examples ribbons scripts industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Xiaomi MySQL Shulou Technology macOS