判断是否是promise对象

通过是判断是否有then和catch方法

function isPromise(val) {
        return (
          val &&
          typeof val.then === "function" &&
          typeof val.catch === "function"
        );
      }

相关文章: