5 ms·
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 )
by bringking 12y 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.
- nijiko 12y agoif (array && !array.length) { /* do something here */ } Check existence as well, this also works for a jQuery selection.