ES6 promise settled callback?
问题 I want to run the same action whether my Promise resolved successfully or not. I don't want to bind the same function to both args of .then . Isn't there a .always like jQuery has? If not, how do I achieve this? 回答1: Isn't there a .always like jQuery has? No, there's not (yet). Though there is an active proposal, so maybe ES2018. If not, how do I achieve this? You can implement the finally method yourself like this: Promise.prototype.finally = function(cb) { const res = () => this const fin =