【发布时间】:2014-06-21 17:23:44
【问题描述】:
我通过关注this 在 mac 上构建了 spidermonkey。在 build-release/dist/bin 下,可执行文件是 js24 而不是 js(根据 this )。
但是,当我使用 js24 运行 shell 时,像 1+2 这样的表达式正在工作,但是当我尝试像 setTimeout(function () {}, 500) 这样的事情时,我得到了,
ReferenceError: setTimeout is not defined
我做错了什么?我认为行为与节点外壳相同。
【问题讨论】:
-
setTimeout不是语言的一部分。 -
setTimeout是 window 对象的函数,它是您浏览器中的全局对象。没有window,没有setTimeout -
@MattBurland 明白了,谢谢。 v8 是否也有这种行为并且节点添加了这个?
-
“spidermonkey settimeout”的第一个结果:gist.github.com/kevinoid/3146420
标签: javascript mozilla spidermonkey