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

I've maintained the hoisted index variable and cached the length:

    var i, foods = ['toast', 'cheese', 'wine'], foods_length = foods.length;
    
    for (i = 0; i < foods_length; i++) {
      eat(food[i]);
    }
Prefixing variables with an underscore is not an advantage in readability because it lends nothing to the description of what the variable represents. Its another glyph that you have to visually parse before reaching possible meaning.


I didn't say the underscore is good - it's a necessary evil.

I said consistency is good. And you just proved my point.




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

Search: