ES5 vs ES6 Promises

旧城冷巷雨未停 提交于 2019-12-03 22:57:21
jfriend00

ES5 did not have promises. Libraries like jQuery or Angular had their own custom and non-standard promise implementations.

Popular Promise implementations for use with ES5 are Bluebird (which is compatible with the ES6 standard) and Q (which was not originally compatible with the ES6 standard- though seems to be moving that direction) and RSVP.

Neither are actual polyfills in that they don't get out of the way if native promises are present because they add additional features.

There are some pure polyfills for ES6 promises. Here's one that is a subset of RSVP: https://github.com/stefanpenner/es6-promise.

There are reasons to use more than a polyfill as you can read here: Are there still reasons to use promise libraries like Q or BlueBird now that we have ES6 promises?

Asking for a recommendation of a specific polyfill library is considered off-topic here on Stack overflow so I won't comment on that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!