MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHorror/comments/1c9vf63/incredible/
r/ProgrammerHorror • u/idontunderstandunity • Apr 21 '24
10 comments sorted by
20
This is what happens when a programmer feels an excess of cleverness.
KISS -- Keep It Simple, Stupid.
5 u/Careful_Confidence67 Apr 22 '24 OP on a phone account here, I posted this because I thought it’s a bad and complicated way to do the task 2 u/Peregrine2976 Apr 22 '24 Yeah, I got that! 1 u/codeguru42 Apr 22 '24 I agree. The nesting isn't the problem here. I don't understand why the spread operator at each level...oh wait. Are they trying to do a deep copy?p.s. The mobile app is hot garbage. I got the "empty response" error like 20 times before it finally posted.
5
OP on a phone account here, I posted this because I thought it’s a bad and complicated way to do the task
2 u/Peregrine2976 Apr 22 '24 Yeah, I got that! 1 u/codeguru42 Apr 22 '24 I agree. The nesting isn't the problem here. I don't understand why the spread operator at each level...oh wait. Are they trying to do a deep copy?p.s. The mobile app is hot garbage. I got the "empty response" error like 20 times before it finally posted.
2
Yeah, I got that!
1
I agree. The nesting isn't the problem here. I don't understand why the spread operator at each level...oh wait. Are they trying to do a deep copy?
p.s. The mobile app is hot garbage. I got the "empty response" error like 20 times before it finally posted.
Spread em
As far as cursed js examples go, i think this one is beautiful
Sure the object is quite nested, but all the spreads just to update the value is even worse.
info[category][subclass][index][id] = value;
And if you need a deep copy of the object before setting the value, use structuredClone first.
structuredClone
1 u/idontunderstandunity Apr 22 '24 I'm stupid, structuredClone reduced this mess to just 3 lines in total
I'm stupid, structuredClone reduced this mess to just 3 lines in total
3
we have a tool for that and its called structuredClone
Can someone explain this to me?
20
u/Peregrine2976 Apr 22 '24
This is what happens when a programmer feels an excess of cleverness.
KISS -- Keep It Simple, Stupid.
5
u/fakehalo Apr 22 '24
Spread em
5
u/cidit_ Apr 22 '24
As far as cursed js examples go, i think this one is beautiful
1
u/meandyouandyouandme Apr 22 '24
Sure the object is quite nested, but all the spreads just to update the value is even worse.
And if you need a deep copy of the object before setting the value, use
structuredClonefirst.3
u/Symbroson Apr 22 '24
we have a tool for that and its called
structuredClone2
u/TurgantheMage Apr 22 '24
Can someone explain this to me?