Underscore: isEmpty

Created on 3 Nov 2018  ·  3Comments  ·  Source: jashkenas/underscore

_.isEmpty(11)
true
_.isEmpty(''+11)

false

Most helpful comment

from doc
_.isEmpty(object) ... Returns true if an enumerable object ... For strings and array-like objects _.isEmpty checks if the length property is 0.

11 is not object, and has no the length property
'11' is string and has the length property

All 3 comments

But I don't think this can be considered an issue, since ''+11 is equivalent to '11', and therefore not empty.

from doc
_.isEmpty(object) ... Returns true if an enumerable object ... For strings and array-like objects _.isEmpty checks if the length property is 0.

11 is not object, and has no the length property
'11' is string and has the length property

Seems to be resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jdalton picture jdalton  ·  6Comments

xiaoliwang picture xiaoliwang  ·  3Comments

acl0056 picture acl0056  ·  5Comments

afranioce picture afranioce  ·  8Comments

jezen picture jezen  ·  8Comments