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

In Javascript, `for..in` prints the keys. In an object, the keys are the properties. In an array, the keys are the indexes. If you want the values then use the key to lookup the value from the object or array.

Either way it's entirely consistent: an iterator that works on both objects and arrays and prints the keys without guaranteeing order. Does that clear up the confusion?



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: