Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Here's a jsperf that tests just the arguments copy via slice, while loop, or for loop: http://jsperf.com/args-copy

In the browsers I tested in, it does indeed seem to be significantly faster to copy the array via a normal loop (in Chrome, Firefox, and WebKit mobile, at least). That said, don't start optimizing everything into for loops unless you've identified the code as a bottleneck. It's not worth the additional complexity for a function that's rarely called.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: