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

markvr picture markvr  路  3Comments

marcalj picture marcalj  路  5Comments

afranioce picture afranioce  路  8Comments