Because that loop doesn't do what you think it does?
for...in iterates over the keys of an object, but for in in vue iterates over the elements of an array.
for...in iterates over the keys of an object, but for in in vue iterates over the elements of an array.
It is you who doesn't think that loop does what it actually does.
Please read the spec and verify with your favorite JS runtime before continuing this argument.
for (x in [6,1,6,2,6,3]) {
console.log(x);
}
Please run this in your browser console and tell me if it iterates over the elements of the array.Also Vue's directives are not JS. It's a separate DSL. I've repeated this enough so I'll end this discussion here.
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.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?