如果一个变量是 Object, 有 then 和 catch 方法, 就认为是 Promise
const isPromise = (val) => {return isObject(val) && isFunction(val.then) && isFunction(val.catch);};

function isPromise(obj) {return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'}
!! 在js 中的作用
一个 “ ! “ 将变量转为一个boolean类型的值,那么两个连续的 “ ! “号叠加就会把变量转为它理应代表的布尔值。
number类型: 不为0 就,!!num 等于true;string类型: 不为"" (空字符串),!!str 等于true;!!null 等于false!!undefined 等于false!!{} 等于 true //注意:对象就算为空都会被转为true!!function(){} 等于 true //注意:这样写function 并不会执行function,所以就算function里面写任何东西都会返回trueconsole.log(!!0); //falseconsole.log(!!123); //trueconsole.log(!!"some"); //trueconsole.log(!!""); //falseconsole.log(!!undefined) //falseconsole.log(!!null) //false
