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
64 comments sorted by
View all comments
Show parent comment
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.
View all comments
Show parent comment
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.