Is setTimeout a part of JavaScript it self or it i

2019-04-06 17:14发布

Is setTimeout a part of JavaScript it self or it is just an api that the browser provides ?

Is it a part of ES ?

3条回答
男人必须洒脱
2楼-- · 2019-04-06 17:45

From MDN:

Specification WHATWG HTML Living Standard

… and you won't see it in ECMA-262 5.1.

查看更多
闹够了就滚
3楼-- · 2019-04-06 17:55

It is part of the window object in the browser, not defined in ECMAScript. Therefore, other environments such as Node are not guaranteed to have it.

查看更多
戒情不戒烟
4楼-- · 2019-04-06 18:10

The setTimeout() function is actually exposed by the browser's window object as as such they aren't necessarily defined in the ECMAScript specification because they're not JavaScript features, they are features of the browser itself.

You can see from the specification section in the previously linked documentation that it uses the WHATWG HTML Living Standard :

enter image description here

As opposed to a Javascript function like split() that explicitly uses EMACScript :

enter image description here

查看更多
登录 后发表回答