There's already a similar question, and its answer is:
typeof yourVariable === 'object' && yourVariable !== null
However, that would also include HTML elements like document.body
. Is there a way to detect if a value is a plain object?
Edit: By "plain object", I mean "user-created" objects. I don't want to match class instances, for example, or DOM elements. Just objects used as hashes, as @VLAZ suggested in the comments.