Timeline for How to merge two arrays in JavaScript and de-duplicate items
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 1, 2021 at 5:54 | comment | added | Kamil Kiełczewski | @Pitouli you are right - I update answer and remove solutions which changes input arrays F,I,K - because benchmark gives wrong results for it (when I have more time in future I will try to benchmark dropped solutions again) | |
Mar 1, 2021 at 5:52 | history | edited | Kamil Kiełczewski | CC BY-SA 4.0 |
deleted 2194 characters in body
|
Mar 1, 2021 at 3:32 | comment | added | Pitouli | I confirm my suspicion. I updated the test bench so the array is parsed from an unmodified json. Obviously, every test is a bit slower, but it does not impact the ranking. And the K test is significantly slower than the C, D, L & M tests (on Mac Chrome). jsbench.me/mpklq0sj6l/1 | |
Mar 1, 2021 at 3:12 | comment | added | Pitouli | @KamilKiełczewski : Careful! I have a strong suspicion that there is a bug in the test. When you add a console.log with the length of the arrays, you observe that the length is 0 in most cases. It feels like the array is not correctly reset between each run. And then of course, merging two null array is a very fast operation ;) This seems to be confirmed by this answer stackoverflow.com/a/66129415/2137476 where the K solution is fast, but less than the C solution (careful ; only look at the % comparaison; there is an error in the snippet and the chrono is wrong) | |
Jan 20, 2021 at 17:46 | comment | added | Kamil Kiełczewski | @Marco I don't know how to improve first snippet without loosing performance or simplicity - but I'm open to your solution - feel free to create new answer where you improve this solution in such way - everybody will be happy :) | |
Jan 20, 2021 at 17:21 | comment | added | Marco | why don't you improve the first snippet and remove the code duplication? | |
Oct 15, 2020 at 17:34 | history | edited | Kamil Kiełczewski | CC BY-SA 4.0 |
added 28 characters in body
|
Oct 15, 2020 at 11:50 | history | edited | Kamil Kiełczewski | CC BY-SA 4.0 |
edited body
|
Oct 15, 2020 at 11:45 | history | edited | Kamil Kiełczewski | CC BY-SA 4.0 |
added 28 characters in body
|
Oct 15, 2020 at 11:21 | history | answered | Kamil Kiełczewski | CC BY-SA 4.0 |