Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a promise an API of the browser or a JavaScript object?

The Document object or the SetTimeout function I understand are web API’s that are included in the JavaScript runtime, whereas an Array or Date object is built into the programming language itself. Where do promises fit?

Are they part of a browser API or are they are part of the JavaScript language that run in the JavaScript engine?

like image 269
Kevo Avatar asked Oct 13 '25 10:10

Kevo


1 Answers

Promises are JavaScript objects. They're documented in the ECMAScript specification.

There's nothing browser-specific about promises, and they're implemented in Node.js, not just browsers.

like image 126
Barmar Avatar answered Oct 14 '25 22:10

Barmar