@trandx/is-object
v3.1.1
Published
This utility function checks if a given value is a plain object. It returns `true` if the value is an object and `false` otherwise.
Downloads
47
Readme
isObject Function
This utility function checks if a given value is a plain object. It returns true
if the value is an object and false
otherwise.
Table of Contents
Installation
pnpm add @trandx/is-object
or
npm i @trandx/is-object
Usage
// Example 1: Check a plain object
const obj = { key: 'value' };
console.log(isObject(obj)); // Output: true
// Example 2: Check an array (not a plain object)
const arr = [1, 2, 3];
console.log(isObject(arr)); // Output: false
// Example 3: Check a null value
const nullValue = null;
console.log(isObject(nullValue)); // Output: false
// Example 4: Check a date object (not a plain object)
const date = new Date();
console.log(isObject(date)); // Output: false
// Example 5: Check an instance of a custom class
class CustomClass {}
const instance = new CustomClass();
console.log(isObject(instance)); // Output: false
If Issues
In case you notice any irregularities in benchmark or you want to add sort library to benchmark score please open issue here
Author
License
MIT