Timeline for Replace array entry with spread syntax in one line of code?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 23, 2021 at 21:51 | comment | added | smac89 | I tested across all major browsers, and this method is the fastest. shorturl.at/aqNV3 | |
Aug 15, 2017 at 14:17 | comment | added | Kokodoko |
You're right! This is very weird. I tested in Chrome and Safari. On Chrome, map is much faster than in Safari. On Safari, spread and assign are almost 10 times as fast as on Chrome!
|
|
Aug 14, 2017 at 12:46 | comment | added | CD.. | I get totally different results with Chrome 60: speard - 13,149, map - 31,702, Object.assign - 12,744. | |
Aug 14, 2017 at 12:39 | comment | added | Kokodoko | Thanks for building this test, that's awesome! When I run it, it seems that Object.assign is fastest with 168.000 ops/second, closely followed by spread with 146.000 ops/second. Map is by far the slowest with only 27.000 ops/second. | |
Aug 14, 2017 at 12:32 | comment | added | CD.. | @Kokodoko I think this will still be faster in this case. I might be missing something, but have a look here: jsperf.com/replace-array-entry | |
Aug 14, 2017 at 12:22 | comment | added | Kokodoko | Hmyeah but if my array has 1000s of entries, I'll have to map through them all each time I want to update one entry. | |
Aug 14, 2017 at 11:48 | history | answered | CD.. | CC BY-SA 3.0 |