Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Check if an object is a Promise
function isPromise(object){
if(Promise && Promise.resolve){
return Promise.resolve(object) == object;
throw "Promise not supported in your environment"
var i = 1;
var p = new Promise(function(resolve,reject){
isPromise(i) // false
isPromise(p) // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment