this post was submitted on 07 Jul 2023
433 points (98.7% liked)

Programmer Humor

19876 readers
182 users here now

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.

Rules

founded 2 years ago
MODERATORS
 

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] -4 points 2 years ago (2 children)

I don't think JS works that way

[–] [email protected] 32 points 2 years ago
[–] [email protected] 21 points 2 years ago* (last edited 2 years ago) (1 children)

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.

[–] [email protected] 16 points 2 years ago

Fuck JS is stupid.

Source: use JS regularly