Hacker News new | ask | show | jobs
by bringking 4385 days ago
Thanks for the article. I agree with most of this, however for empty arrays I find it best just to check length in the "falsy" way. Like -

if ( !array.length ) { //do something }

Seems succinct enough not to require a separate function.

1 comments

if (array && !array.length) { /* do something here */ }

Check existence as well, this also works for a jQuery selection.