How to know if a value its an element in JavaScript?

Solution 1:

You might want to check if the variable is an instance of HTMLElement. So basically

function isElement(element){
    return element instanceof HTMLElement;
}

Also check the mdn-docs, because it's possible that you want to check if your element is a Node (would include text-only nodes) or just an Element (that would include XML-tags in an XML document).