Underscore: _.isEmpty() behavior on date objects.

Created on 26 Jan 2012  路  2Comments  路  Source: jashkenas/underscore

Current implementation of _.isEmpty() always returns true for date objects. Should this be the case?

for example, _.isEmpty(new Date("2/2/2012")) returns true.

question

All 2 comments

isEmpty is a function that works on Objects and Arrays -- behavior on other types of natives is undefined.

@jashkenas

isEmpty is a function that works on Objects and Arrays -- behavior on other types of natives is undefined.

Based on the code _.isEmpty() also works on strings. The documentation should probably be updated.

@fragnemesis

The result of new Date('2/2/2012') is an object ;D
It just doesn't have any enumerable _own properties_ which is why _.isEmpty(...) correctly returns true.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jezen picture jezen  路  8Comments

afranioce picture afranioce  路  8Comments

jdalton picture jdalton  路  6Comments

danilopolani picture danilopolani  路  5Comments

arypbatista picture arypbatista  路  3Comments