-
Notifications
You must be signed in to change notification settings - Fork 27.4k
instanceof doesn't work for $q promises #13545
Comments
A promise can never be an instance of
When not sure if something is a promise or not, then the best option is to use |
No, in JS, "is instance of" doesn't mean what you have described. Angular introduced |
The object returned by Keeping things in the prototype reduces the memory pressure on something as critical as Promises. With this information, can you please elaborate
|
It seems like you're confusing something here. As for var a = new Array();
console.log(a instanceof Array); // true
If we're creating something calling a constructor with the |
Am I missing something? |
I think this makes sense. Currently |
@fa137 By using
(from MDN) |
@thorn0 Thanks for clearing it up! 👍 You are absolutely right then, we need a way to identify whether an object is a promise. EDIT: |
@fa137 Your check doesn't really check if an object is a $q promise. It will as well pass for any promise implementation: jQuery, native ES2015, etc. Even when it comes just to Angular, we have two different kinds of promises here: |
@thorn0 you are right, and this seams like a reasonable request |
http://plnkr.co/edit/a6VE6z
So basically there is no way to check if an object is a $q promise.
The text was updated successfully, but these errors were encountered: