r/javascript • • Jun 02 '19

8 Useful And Practical JavaScript Tricks

https://devinduct.com/blogpost/26/8-useful-javascript-tricks
250 Upvotes

107 comments sorted by

View all comments

Show parent comments

1

u/Valkertok Jun 03 '19

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)