I wanna know whether JS promises were a part of ES5? If so, why it doesn't work sometimes in the older browsers and we have to add a polyfill for them. Also, which polyfill should be added in that case, an ES5 one or ES6? I have a little confusion regarding that.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With