NowImCoding Profile Image
NowImCoding
11 months ago
5
1.2K
0
60
😂 Every JavaScript dev has lived this moment… You think you’re about to do something simple: “I’ll just use array.sort() to sort these numbers.” JavaScript: “Cool… I’ll sort them as strings.” 😈 So you go from [5645, 1, 21, 100000, 30, 4, 566, 56] to [1, 100000, 21, 30, 4, 56, 5645, 566] Why? Because by default, JavaScript sorts alphabetically, not numerically. It compares "100000" and "21" like strings not numbers so "1" comes before "2". This is one of those moments where JavaScript quietly smiles while your logic collapses. The fix every dev learns the hard way: Copy code Js array.sort((a, b) => a - b) And just like that… reality returns. This meme is funny because it’s true JavaScript doesn’t do what you mean, it does exactly what you ask. And sometimes what you ask is… chaos 😅 If you’ve ever been confused by this, congrats you’re officially a real JavaScript developer now.
Download video without watermark
original sound
•
10s