工具函数 判断是否是promise对象

判断是否是promise对象

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

function isPromise(val) {
        return (
          val &&
          typeof val.then === "function" &&
          typeof val.catch === "function"
        );
      }
posted @ 2021-03-23 14:53  黑黑哈哈  阅读(274)  评论(0编辑  收藏  举报