Skip to main content

Command Palette

Search for a command to run...

Today's npm package: objectorarray

Published
โ€ข1 min read
Today's npm package: objectorarray
P

I am developer from India currently based in Berlin, Germany.

I am very interested in Design, though I don't design ๐Ÿ˜‰ I take care of it while making my apps.

Photography, videography and having random conversation over beer are my activities of spare time. Timelapses and hyperlapses make me wonder all the time ๐Ÿ˜Š

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.