I don't think JS works that way
It does.
Array.prototype.sort if no callback is passed to it will coerce non-undefined elements to strings when sorting. It does do that.
Array.prototype.sort
undefined
To sort numbers passing a function like (a, b) => a - b is good enough.
(a, b) => a - b
Fuck JS is stupid.
Source: use JS regularly
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
I don't think JS works that way
It does.
Array.prototype.sort
if no callback is passed to it will coerce non-undefined
elements to strings when sorting. It does do that.To sort numbers passing a function like
(a, b) => a - b
is good enough.Fuck JS is stupid.
Source: use JS regularly