eval-Evaluation

Posted zzfx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了eval-Evaluation相关的知识,希望对你有一定的参考价值。

eval is a function which evaluates a string as though it were an expression and returns a result; in others, it executes multiple lines of code as though they had been included instead of the line including the eval.

 

javascript[edit]

In JavaScripteval is something of a hybrid between an expression evaluator and a statement executor. It returns the result of the last expression evaluated.

Example as an expression evaluator:

foo = 2;
alert(eval(‘foo + 2‘));

Example as a statement executor:

foo = 2;
eval(‘foo = foo + 2;alert(foo);‘);

One use of JavaScript‘s eval is to parse JSON text, perhaps as part of an Ajax framework. However, modern browsers provide JSON.parse as a more secure alternative for this task.

https://en.wikipedia.org/wiki/Eval

 

 Implementation

In interpreted languageseval is almost always implemented with the same interpreter as normal code. In compiled languages, the same compiler used to compile programs may be embedded in programs using the eval function; separate interpreters are sometimes used, though this results in code duplication.

 

http://dictionary.sensagent.com/Eval/en-en/

以上是关于eval-Evaluation的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数