Sunny-117 / js-challenges

✨✨✨ Challenge your JavaScript programming limits step by step
https://juejin.cn/column/7244788137410560055
2.03k stars 235 forks source link

Promise A+规范要求obj是一个对象或者函数,这样写是否是更合理一点 #471

Open liuruil opened 1 year ago

liuruil commented 1 year ago

Promise A+规范要求obj是一个对象或函数,这样写是否是更合理一点 address: https://promisesaplus.com/#point-53

function isPromise(obj) {
  return !!(obj && (typeof obj === "object" || typeof obj === 'function') && typeof obj.then === "function");
}

Originally posted by @liuruil in https://github.com/Sunny-117/js-challenges/issues/8#issuecomment-1427352574