The only difference in Vue is not having to explicitly declare the variable. But so what?
You said "strings are magic and not code" to which I said "all code is text so there are no magic strings". Now you and the other poster keep saying "well this string isn't the same syntax as JS" but I don't see what the point is. Why does it have to be valid JS?
Again, you can embed syntax within each other just fine. JSX has HTML tags inside JS. HTML has tags like <style> and <script> for other languages (regardless of what the default language is or what parses it).
So, for the last time, what's the actual argument?
> How is it invalid? Here's the syntax about a for..in loop
for (variable in object) {
statement
}
And here's the syntax for Vue's for..in loop. Only one of it is somewhat Javascript:
item in items
(item, index) in items
(val, key) in object
(val, name, index) in object
And, of course, there's an extension to that
v-for="item in items" :key="item.id"
Edit: additionally, from that very link: "for...in should not be used to iterate over an Array where the index order is important." But this doesn't concern Vue, it maintains the order in its for..in.
It does exactly what I think it does, which is either iterate over the properties if it's an object or the elements if it's an array. This is true for Vue and Javascript. I suggest you read the documentation I linked earlier.
Also Vue's directives are not JS. It's a separate DSL. I've repeated this enough so I'll end this discussion here.
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?
You said "strings are magic and not code" to which I said "all code is text so there are no magic strings". Now you and the other poster keep saying "well this string isn't the same syntax as JS" but I don't see what the point is. Why does it have to be valid JS?
Again, you can embed syntax within each other just fine. JSX has HTML tags inside JS. HTML has tags like <style> and <script> for other languages (regardless of what the default language is or what parses it).
So, for the last time, what's the actual argument?