setTimeout():如果没有在EcmaScript规范中定义,我在哪里可以了解它是如何工作的? [英] setTimeout(): If not defined in EcmaScript spec, where can I learn how it works?

查看:117
本文介绍了setTimeout():如果没有在EcmaScript规范中定义,我在哪里可以了解它是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在关于setTimeout()的其他问题,用户提到 如果函数参数是一个字符串,它在全局范围内被评估,否则它不是 。这让人大开眼界,所以我试图找到有关setTimeout实际工作原理的更多信息,但它不是EcmaScript规范的一部分,甚至MDN都没有我在SO中找到的那些特定信息。

I had another question in SO about setTimeout(), where a user mentioned that if the function argument is a string it gets evaluated in global scope, other wise it's not. This was an eye-opener, so I tried to find more info about how setTimeout actually works, but it's not part of the EcmaScript spec and not even MDN had that specific of of information I found in SO.

关于 setTimeout()如何运作,是否有一些很好的参考?

Is there some good reference about how setTimeout() works?

推荐答案

setTimeout 等等因为它们不在ECMAScript规范中'不是JavaScript功能。它们是浏览器环境的窗口对象的功能。其他环境(Windows Scripting Host,NodeJS等)不一定具有这些功能。

setTimeout and such aren't in the ECMAScript specification because they're not JavaScript features. They're features of the browser environment's window object. Other environments (Windows Scripting Host, NodeJS, etc.) won't necessarily have those features.

W3C一直在尝试标准化窗口对象及其各种功能(包括 setTimeout ),最新版本是HTML5规范的计时器部分。很多都是编码浏览器已经做过的事情,虽然其中一些(比如说最小间隔值必须 4 [毫秒])似乎(对我来说)是API规范和实现的不合适似乎构成了自己的想法(在测试中,你可以看到当前的浏览器愉快地做了一个更短的间隔,Opera的明显例外似乎做了规范所说的。)

The W3C has been trying to standardize the window object and its various features (including setTimeout), the latest is in the timers section of the HTML5 spec. A lot of it is codifying what browsers already do, although some of it (like saying that the minimum interval value must be 4 [milliseconds]) seems (to me) to be out-of-place for an API specification and implementations seem to make up their own minds (in tests, you can see current browsers happily doing a shorter interval, with the apparent exception of Opera which appears to do what the spec says).

这篇关于setTimeout():如果没有在EcmaScript规范中定义,我在哪里可以了解它是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆