The modern build of lodash's `_.isObject` as a module.
npx @tessl/cli install tessl/npm-lodash--isobject@3.0.0A standalone implementation of lodash's _.isObject utility function that checks if a value is the ECMAScript language type of Object. This modular build provides a lightweight, zero-dependency alternative to importing the entire lodash library when only the isObject functionality is needed.
npm install lodash.isobjectconst isObject = require('lodash.isobject');const isObject = require('lodash.isobject');
// Objects return true
console.log(isObject({})); // => true
console.log(isObject({ a: 1 })); // => true
// Arrays are objects
console.log(isObject([1, 2, 3])); // => true
console.log(isObject([])); // => true
// Functions are objects
console.log(isObject(function() {})); // => true
console.log(isObject(() => {})); // => true
// Regular expressions are objects
console.log(isObject(/abc/)); // => true
// Boxed primitives are objects
console.log(isObject(new Number(5))); // => true
console.log(isObject(new String(''))); // => true
// Primitives and null return false
console.log(isObject(null)); // => false
console.log(isObject(undefined)); // => false
console.log(isObject('string')); // => false
console.log(isObject(42)); // => false
console.log(isObject(true)); // => falseChecks if a value is the ECMAScript language type of Object, including arrays, functions, objects, regexes, and boxed primitives.
/**
* Checks if `value` is the ECMAScript language type of `Object`.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
*/
function isObject(value);Parameters:
value (*): The value to checkReturns:
boolean: Returns true if value is an object, else falseBehavior:
true for ECMAScript language type of Object, which includes:
{})[])function() {})/pattern/)new Date())new Number(), new String(), new Boolean())false for:
null (special case: typeof null === 'object' but null is falsy)undefined!!value && (typeof value == 'object' || typeof value == 'function')Usage Examples:
const isObject = require('lodash.isobject');
// Different object types
isObject({}); // => true
isObject({ name: 'John' }); // => true
isObject([1, 2, 3]); // => true
isObject(function hello() {}); // => true
isObject(/pattern/); // => true
isObject(new Date()); // => true
isObject(new Number(42)); // => true
// Non-object types
isObject(null); // => false
isObject(undefined); // => false
isObject('hello'); // => false
isObject(123); // => false
isObject(true); // => false
isObject(Symbol('sym')); // => false