Of course !! sorry but English it's not my first language, however I don't understand the final example. Can you explain me better why in both loops doesn't print "mixed"?
I hope it's clearer now :)
Okay great, in the first solution I used a for ... in loop with loops through the property name of an array. That array has the following property names 0, 1, 2, type.
The second solution I use for ... of which loops through the property values of an array, basically the elements of the array. 1, 2, "nedy";
If I want to print mixed which a property of the items array, I would have to do this console.log(items.type) // "mixed".
so for ... in deals with the property names, for ... of deals with the property values(elements of the array).
Of course !! sorry but English it's not my first language, however I don't understand the final example. Can you explain me better why in both loops doesn't print "mixed"?
I hope it's clearer now :)
Okay great, in the first solution I used a
for ... in
loop with loops through the property name of an array. That array has the following property names0, 1, 2, type
.The second solution I use
for ... of
which loops through the property values of an array, basically the elements of the array.1, 2, "nedy"
;If I want to print mixed which a property of the items array, I would have to do this
console.log(items.type) // "mixed"
.so
for ... in
deals with the property names,for ... of
deals with the property values(elements of the array).Thanks for this explanation, now I understand better!
You are welcome @camicode