Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There would be a significant performance impact if `.sort()` argumentless had to traverse the list and checked all inputs were numbers. It's better to pass a sort function -- that is how the API is meant to be used.

I agree that without an argument it should just be a fatal error, but if it were to have any sort of functionality, it should convert all to strings.

This is consistent among JS's apis, and pretty much the origin of all the 'js wut' moments on the internet. Everything in JS can be converted into a string. If you do something stupid with disparate types, it will likely turn operands into strings and compare them that way.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: