js find type element code example
Example 1: how to know type of dom element in js
let divElement = document.createElement('div');
if (divElement.nodeName == "DIV") //true
if (divElement.nodeName == "<div>") //false
Example 2: javascript check if variable is object
//checks if is object, null val returns false
function isObject(val) {
if (val === null) { return false;}
return ( (typeof val === 'function') || (typeof val === 'object') );
}
var person = {"name":"Boby Snark"};
isObject(person);//true