Skip to main content

Today's npm package: objectorarray

Published 1 min readMarkdown
Part of seriesPackage of the Day
Today's npm package: objectorarray

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.

About the author

  • 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 😊

No comments yet. Be the first to comment.