programming-examples/js/Vre2/Validate whether a given value is object or not.js

11 lines
292 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function is_object(value)
{
var datatype = typeof value;
return datatype === 'function' || datatype === 'object' && !!value;
}
console.log(is_object({name: 'Robert'}));
console.log(is_object('bar'));
console.log(is_object(72));