jashkenas / underscore

JavaScript's utility _ belt
https://underscorejs.org
MIT License
27.33k stars 5.53k forks source link

Add additional info for isDate documentation #2821

Closed khasburrahman closed 3 years ago

khasburrahman commented 4 years ago

This additional info might be helpful for some people that doesn't aware that initializing Date with invalid date string will still returns a Date object. So that checking invalid Date with isDate will returns true.

_.isDate() function only checks if a variable type is Date not check if it the value is valid.

jgonggrijp commented 4 years ago

Thank you for taking the effort to submit a pull request, @khasburrahman.

I understand that _.isDate(new Date('invalid')) === true is confusing. But the confusing part is that new Date('invalid') returns an actual Date. I think an explanation for that belongs on a web page about Date, such as this one, instead of on a web page about Underscore. Would you agree with that?

jgonggrijp commented 4 years ago

@khasburrahman if you have not replied yet by June 30, I will close this PR for the time being. The PR can still be reopened after that if you wish. Thank you for understanding.