Danny Fox Danny Fox - 1 year ago 210
Javascript Question

Check if a value is an object in javascript

How to check in JavaScript if the value of a variable is an object?

Answer Source

Try using typeof(var) and/or var instanceof something.

EDIT: This answer gives an idea of how to examine variable's properties, but it is not a bulletproof recipe (after all there's no recipe at all!) for checking whether it's an object, far from it. Since people tend to look for something to copy from here without doing any research, I'd highly recommend that they turn to the other, most upvoted (and correct!) answer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download