Is setTimeout a part of JavaScript it self or it i

2019-04-06 17:55发布

问题:

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

Is it a part of ES ?

回答1:

From MDN:

Specification WHATWG HTML Living Standard

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



回答2:

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 :

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



回答3:

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.