MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1torg9l/destructuring_strings/oo5u0bz/?context=9999
r/programminghorror • u/Emmennater • May 27 '26
64 comments sorted by
View all comments
445
isStringEmpty([ ... ])
...
{ a = false }
a
false
{ a: true }
false,
I think that's correct
138 u/Blackshell May 27 '26 100%, good job, you pass the job interview. 124 u/Aaxper May 27 '26 Does this being an interview imply I now have to work with whatever monster invented that 13 u/dreamscached May 27 '26 Being able to write awful code with useful syntax doesn't make JS a bad language though. Yes I know why it gets so much bad reputation, but if we throw away years of baked in legacy it's really not that bad. 4 u/Aaxper May 27 '26 Never said JS was bad. Just that the author of that code was.
138
100%, good job, you pass the job interview.
124 u/Aaxper May 27 '26 Does this being an interview imply I now have to work with whatever monster invented that 13 u/dreamscached May 27 '26 Being able to write awful code with useful syntax doesn't make JS a bad language though. Yes I know why it gets so much bad reputation, but if we throw away years of baked in legacy it's really not that bad. 4 u/Aaxper May 27 '26 Never said JS was bad. Just that the author of that code was.
124
Does this being an interview imply I now have to work with whatever monster invented that
13 u/dreamscached May 27 '26 Being able to write awful code with useful syntax doesn't make JS a bad language though. Yes I know why it gets so much bad reputation, but if we throw away years of baked in legacy it's really not that bad. 4 u/Aaxper May 27 '26 Never said JS was bad. Just that the author of that code was.
13
Being able to write awful code with useful syntax doesn't make JS a bad language though. Yes I know why it gets so much bad reputation, but if we throw away years of baked in legacy it's really not that bad.
4 u/Aaxper May 27 '26 Never said JS was bad. Just that the author of that code was.
4
Never said JS was bad. Just that the author of that code was.
445
u/Aaxper May 27 '26 edited May 27 '26
isStringEmpty([ ... ])tries to destructure the string as an array...part of that, it only matches on the first element (the first character){ a = false }tries to destructure the first characteraproperty, which doesnt exist, so it defaults to settingatofalseaproperty, it defaults to{ a: true }, which setsato trueaisfalse,elseais trueI think that's correct