微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 功能和新功能之间的区别

我有时会看到人们在做这个功能(‘alert(“hi”)’),有时他们会做新功能(‘alert(“hi”)’)

这两者有区别吗?

解决方法

spec(第127页)说它们是完全相同的.

15.3.1.1 Function (p1,p2,…,pn,body)

When the Function function is called
with some arguments p1,
body (where n might be 0,that is,
there are no “p” arguments,and where
body might also not be provided),the
following steps are taken:

  1. Create and return a new Function object as if the standard built-in
    constructor Function was used in a new
    expression with the same arguments
    (15.3.2.1).

但是,您应该不惜一切代价避免使用Function cinstructor.它需要评估你传递给它的字符串; eval是邪恶的,也是缓慢的.

原文地址:https://www.jb51.cc/js/158242.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐