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

Besides the first example having a mistake, their suggested solution still isn't best practices;

    for (var i = 0, len = myArray.length; i < len; i++)
    {
        ...
    }
Will perform far faster than doing the comparison on each iteration. Might not be noticeable on an array of 10, but certainly would be on an array of 1k.


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

Search: