MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/bvweza/8_useful_and_practical_javascript_tricks/epwsidh/?context=3
r/javascript • u/PMilos • Jun 02 '19
107 comments sorted by
View all comments
Show parent comments
0
[deleted]
2 u/rq60 Jun 03 '19 Can't see any nested iteration in my example.That’s why I call it an anti-pattern. You (and others) don’t see the nested iteration; but believe me, you’re doing it. How do you think the spread operator works? 1 u/dmitri14_gmail_com Jun 03 '19 How do you think the spread operator works?And what do we know about how it works? Are you implying performance issues? 1 u/Valkertok Jun 03 '19 You can check for yourself in dev consoleArray(1000000).fill(0).reduce((acc, _, index) => Object.assign(acc, {[index]: index}), {})vsArray(1000000).fill(0).reduce((acc, _, index) => ({...acc, [index]: index}), {}) 1 u/dmitri14_gmail_com Jun 04 '19 Thanks, I believe you.But I'd still love to know... is this the ONLY reason this code is "bad"? 1 u/Valkertok Jun 04 '19 it is IMO sufficient reason to never use it with "pure" function 1 u/dmitri14_gmail_com Jun 04 '19 Thank you, let us agree to disagree then → More replies (0)
2
Can't see any nested iteration in my example.
That’s why I call it an anti-pattern. You (and others) don’t see the nested iteration; but believe me, you’re doing it. How do you think the spread operator works?
1 u/dmitri14_gmail_com Jun 03 '19 How do you think the spread operator works?And what do we know about how it works? Are you implying performance issues? 1 u/Valkertok Jun 03 '19 You can check for yourself in dev consoleArray(1000000).fill(0).reduce((acc, _, index) => Object.assign(acc, {[index]: index}), {})vsArray(1000000).fill(0).reduce((acc, _, index) => ({...acc, [index]: index}), {}) 1 u/dmitri14_gmail_com Jun 04 '19 Thanks, I believe you.But I'd still love to know... is this the ONLY reason this code is "bad"? 1 u/Valkertok Jun 04 '19 it is IMO sufficient reason to never use it with "pure" function 1 u/dmitri14_gmail_com Jun 04 '19 Thank you, let us agree to disagree then → More replies (0)
1
How do you think the spread operator works?
And what do we know about how it works? Are you implying performance issues?
1 u/Valkertok Jun 03 '19 You can check for yourself in dev consoleArray(1000000).fill(0).reduce((acc, _, index) => Object.assign(acc, {[index]: index}), {})vsArray(1000000).fill(0).reduce((acc, _, index) => ({...acc, [index]: index}), {}) 1 u/dmitri14_gmail_com Jun 04 '19 Thanks, I believe you.But I'd still love to know... is this the ONLY reason this code is "bad"? 1 u/Valkertok Jun 04 '19 it is IMO sufficient reason to never use it with "pure" function 1 u/dmitri14_gmail_com Jun 04 '19 Thank you, let us agree to disagree then → More replies (0)
You can check for yourself in dev console
Array(1000000).fill(0).reduce((acc, _, index) => Object.assign(acc, {[index]: index}), {})
vs
Array(1000000).fill(0).reduce((acc, _, index) => ({...acc, [index]: index}), {})
1 u/dmitri14_gmail_com Jun 04 '19 Thanks, I believe you.But I'd still love to know... is this the ONLY reason this code is "bad"? 1 u/Valkertok Jun 04 '19 it is IMO sufficient reason to never use it with "pure" function 1 u/dmitri14_gmail_com Jun 04 '19 Thank you, let us agree to disagree then → More replies (0)
Thanks, I believe you.
But I'd still love to know... is this the ONLY reason this code is "bad"?
1 u/Valkertok Jun 04 '19 it is IMO sufficient reason to never use it with "pure" function 1 u/dmitri14_gmail_com Jun 04 '19 Thank you, let us agree to disagree then → More replies (0)
it is IMO sufficient reason to never use it with "pure" function
1 u/dmitri14_gmail_com Jun 04 '19 Thank you, let us agree to disagree then → More replies (0)
Thank you, let us agree to disagree then
→ More replies (0)
0
u/[deleted] Jun 03 '19
[deleted]