Hacker News new | past | comments | ask | show | jobs | submit login

> This is true for Vue and Javascript.

This is not true for javascript at all.

    for (x in [6,1,6,2,6,3]) {
        console.log(x);
    }
Please run this in any javascript runtime.



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?




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

Search: