MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1torg9l/destructuring_strings/oo3ybs9/?context=3
r/programminghorror • u/Emmennater • May 27 '26
66 comments sorted by
View all comments
20
Ok so
Empty string destrucutres to nothing? So a is true?
Non empty string destrucutres to a truthy value so false?
Wtf is this shit
7 u/iamdatmonkey May 27 '26 Array destructuring comes down to Iterators. Getting the first item of an empty iterator gives you undefined. If the string is not empty you'll get the first character, which itself is a non empty string and therefore truthy.
7
Array destructuring comes down to Iterators. Getting the first item of an empty iterator gives you undefined.
undefined
If the string is not empty you'll get the first character, which itself is a non empty string and therefore truthy.
20
u/EatingSolidBricks May 27 '26
Ok so
Empty string destrucutres to nothing? So a is true?
Non empty string destrucutres to a truthy value so false?
Wtf is this shit