javascript typeof object check code example
Example 1: type of javascript
if (typeof(value) !== "undefined") {
}
Example 2: check data type in javascript
typeof("string");
typeof(123);
Example 3: javascript check if variable is object
function isObject(val) {
if (val === null) { return false;}
return ( (typeof val === 'function') || (typeof val === 'object') );
}
var person = {"name":"Boby Snark"};
isObject(person);
Example 4: how to get type of variable in javascript
> typeof "foo"
"string"
> typeof true
"boolean"
> typeof 42
"number"
Example 5: check data type in js
var x = "Hello World";
typeof x;