Destructuring Strings

Destructuring Strings
javascript-memes, destructuring-memes, code-smell-memes, over-engineering-memes, cursed-code-memes | ProgrammerHumor.io

Someone discovered that strings are iterable in JavaScript and decided to weaponize destructuring syntax for evil. The function takes a string, destructures its first character (because strings are just fancy arrays, apparently), and checks if it exists.

Empty string? No first character to destructure, so a stays false from the default parameter. Any actual string? First character exists, so a becomes truthy. It's technically correct, which is the worst kind of correct.

This is the JavaScript equivalent of using a flamethrower to light a candle. Sure, it works, but your code reviewers will question every life choice that led them to this moment. Just use str.length === 0 like a normal person who values their employment.

More Like This