Javascript Check Is Array Empty

Aug 21, 2018
function isArrayEmpty(array) {  return !Array.isArray(array) || !array.length}

NOTE: will return true if array is not array (null, string, integer, etc.)

Using lodash isEmpty.

_.isEmpty([])      // true_.isEmpty([1])     // false

NOTE: if variable is boolean or integer, it will always return true.

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.