check what type of object a variable is javascript code example
Example 1: check data type in javascript
typeof("string"); //string
typeof(123); //number
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