First, eval is the basic rule of use
The ·1 eval () function computes a string and executes the JavaScript code in it.
2 eval (string)
3 string required. The string to evaluate, which contains the JAVASCRIPT expression to evaluate or the statement to execute.
4 eval () has only one parameter.
5 eval Use is more unsafe, forget to use cautiously
Two, Eval's error usage method
• 1 If the incoming argument is not a string, it returns the function directly.
• 2 If the argument is a string, it compiles the string as JavaScript code, if the compiler loser throws a syntax error exception.
• 3 If the compilation succeeds, begin executing this piece of code and return the value of the last expression or statement in the string.
4 if the last expression or statement has no value, it will eventually return to undefined.
Iii. Examples of Use
I have looked up a lot of information, but also very vague, I hope to understand the great God can guide guidance!
The above the JS eval () function of some of the ideas are small to share the whole of the content of everyone, hope to give you a reference, but also hope that we support the cloud habitat community.