Pankaj Patel
Pankaj Patel

Follow

Pankaj Patel

Follow
Today's npm package: objectorarray

Today's npm package: objectorarray

Pankaj Patel's photo
Pankaj Patel
ยทJul 16, 2021ยท

1 min read

Play this article

Today's npm package is objectorarray

This package can help you quickly checking if the variable is an Object or Array.

Of course there are direct and vanilla-js ways to check if any value is an object or array.

But having a centralized package to avoid writing long comparison is easier to keep the project more readable and sane.

const isObjectOrArray = require('objectorarray');

console.log(isObjectOrArray(null)) // false
console.log(isObjectOrArray(false)) // false
console.log(isObjectOrArray([])) // true
console.log(isObjectOrArray({})) // true
console.log(isObjectOrArray(() => {})) // false
console.log(isObjectOrArray(new Date)) // true

Stay tuned for tomorrow's package of the Day.

ย 
Share this