Thenables in JavaScript phục vụ cho bài viết trên (ok)
Thenables in JavaScript
// A thenable is an object with a `then()` function. The
// below thenable behaves like a promise that fulfills with
// the value `42` after 10ms.
const thenable = {
then: function(onFulfilled) {
setTimeout(() => onFulfilled(42), 10);
}
};
Promise.resolve().
then(() => thenable).
then(v => {
v; // 42
});Thenables in the Wild
Last updated