eval 函数 代替函数

eval()函数 (eval() function)

eval() function is a predefined global function in JavaScript and it is used to evaluate (execute) an expression, which is passed to the function as a parameter. It can also evaluate any JavaScript code.

eval()函数是JavaScript中预定义的全局函数,用于评估(执行)表达式,该表达式作为参数传递给该函数。 它还可以评估任何JavaScript代码。

Syntax:

句法:

    eval(expression);

Here, expression is the JavaScript code or any expression having values or variables.

此处, 表达式是JavaScript代码或具有值或变量的任何表达式。

Example:

例:

<html>
<head>
<title>JavaScipt Example</title>
</head>
<body>
<script>
var num1 = 100;
var num2 = 200;
var num3 = eval("num1 + num2"); //add num1 and num2
var num4 = eval("num3 + 100"); //add num3 and 100
var str = eval("num4.toString(16)"); //convert num4 value to hex
document.write("num3: " + num3 + "<br>");
document.write("num4: " + num4 + "<br>");
document.write("str: " + str + "<br>");
</script>
</body>
</html>

Output

输出量

num3: 300
num4: 400
str: 190

翻译自: https://www.includehelp.com/code-snippets/eval-function-with-example-in-javascript.aspx

eval 函数 代替函数

eval 函数 代替函数_eval()函数以及JavaScript中的示例相关推荐

  1. matlab中now函数_now()方法以及JavaScript中的示例

    matlab中now函数 JavaScript now()方法 (JavaScript now() method) now() method is a Date class method, it is ...

  2. include函数_include()函数以及JavaScript中的示例

    include函数 includes() is a predefined function in JavaScript, which is used to check whether a given ...

  3. 用JavaScript中的示例进行fill()函数

    fill() is a predefined function in JavaScript, which is used to fill all elements of an array with a ...

  4. to_number用法示例_Number()函数以及JavaScript中的示例

    to_number用法示例 Number()函数 (Number() function) Number() function is a predefined global function in Ja ...

  5. 使用JavaScript中的示例的escape()函数

    While transferring the data over the network or sometimes while saving data to the database, we need ...

  6. java中isnan函数_isNaN()函数以及JavaScript中的示例

    java中isnan函数 Prerequisite: NaN property in JavaScript 先决条件: JavaScript中的NaN属性 isNaN()函数 (isNaN() fun ...

  7. JavaScript中带有示例的Math.log10()方法

    JavaScript | Math.log10()方法 (JavaScript | Math.log10() Method) Math operations in JavaScript are han ...

  8. JavaScript中带有示例的Math.abs()方法

    JavaScript | Math.abs()方法 (JavaScript | Math.abs() Method) Math operations in JavaScript are handled ...

  9. 使用JavaScript中的示例编号MAX_VALUE属性

    数字MAX_VALUE属性 (Number MAX_VALUE Property) MAX_VALUE Property is a Number property in JavaScript and ...

最新文章

  1. python画图三维-Python使用matplotlib绘制三维图形示例
  2. java格式化星期_在Java中使用SimpleDateFormat格式化星期几
  3. mongodb 查询内嵌文档
  4. [转]Windows 性能监视器工具-perfmon
  5. 系统学习机器学习之总结(三)--多标签分类问题
  6. jQuery学习_具备吸附功能的拖曳框
  7. Julia : Formatting库的 fmt Base.@sprintf
  8. 11.30上海交大PMP试题每日一题
  9. NOPI将数据导出至EXCEL表格
  10. 复工后的前端学习建议,非常实用!
  11. Linux下ps -ef和ps aux
  12. HDU---2037
  13. 漫话:如何给女朋友解释为什么有些网站域名不以www开头
  14. 爬虫6_周杰伦新歌《Mojito》B站弹幕分析
  15. Grafana 任意文件读取漏洞复现
  16. Mybatis 通过拦截器动态修改SQL
  17. 学习 Python 编程的 11 个受用终身的技巧
  18. composer 安装laravel 5.5 苹果终端
  19. IE6兼容PNG_se7en3_新浪博客
  20. 通俗的解释『多项式时间』

热门文章

  1. 修改 this 指向
  2. 分享下自己的EmpireofCode进攻策略 https://empireofcode.com/ https://empireofcode.com/game/#
  3. Html5开发-使用Canvas绘制图片
  4. webpack联邦模块之webpack运行时
  5. 让使用MSN就像访问网页一样容易!
  6. IP通信基础 4月1日
  7. ubuntu(deepin)安装apache2并支持php7.0
  8. javascript的浏览器Bom详解,window、location、history对象
  9. 学习编程,英语很重要!!
  10. 内核态与用户态【转载】