GitHub 6248★

Check if a value is an object

JavaScript version

const isObject = (v) => v !== null && typeof v === 'object';

TypeScript version

const isObject = (v: any): boolean => v !== null && typeof v === 'object';

Examples

isObject(null); // false
isObject('hello world'); // false

isObject({}); // true
isObject([]); // true
Follow me on and to get more useful contents.