DEV Community

loading...

Discussion on: CodeRecipe: How to reverse an array in JavaScript

Collapse
aminnairi profile image
Amin • Edited

I decided to test another way of thinking this. Here are the results:

with slice and reverse: 83.085ms
With one loop: 309.763ms

Source-code and tests are available here.

I though that using one for loop (compared to a chained call using slice & reverse) would be more performant. I was wrong.

What Samantha showed is great work, I'm trying to show alternatives and another way of thinking this through.

Collapse
samanthaming profile image
Samantha Ming Author

Fantastic! Thanks for sharing this! I’ll add this to my notes 👏👏👏

Collapse
mohamedbenoba profile image
Mohamed_Benoba

Good work man!

Forem Open with the Forem app