Reputation: 12704
Related: Check if object is a jQuery object
I have an object x
, and after running console.log(x)
Chrome's debugger shows me this:
How can I check if x
is a jQuery.Event
using JavaScript? (I've tried Object.getPrototypeOf
, toString
and obj.constructor
).
Upvotes: 5
Views: 1309
Reputation: 1012
Agreeing @Rocket's comment: instanceof
is the way to go. You can try this on SO's website in the JS console
var x = $.Event()
x instanceof $.Event
More information can be found in this eerily similar post: https://stackoverflow.com/a/1853246/1883547
Upvotes: 6