Curiosity strikes me: how can I determine if the variable myVar
is a node?
I could simply check myVar.nodeType
, but that might be misleading with something like {nodeType:1}
So, naturally, I start to wonder if there's a way to do this instead:
myVar instanceof Node
Edit
Interesting discovery - it seems that we have a Node
constructor, so using instanceof Node
actually does work!
Maybe I should have tested my theory before asking...
Let's not mistake my question for a duplicate of Check if variable is a valid node element. Unlike that question, mine doesn't make any assumptions about whether myVar
is a node or empty.