Nice post!
thanks to you, I started to understand a little about arrays,but there is a point that I don't understand in the last example of your code when you want to add a property to the array using the type method: because as a final result it prints 0 , 1 , 2 ,nedy and not mixed? And in other for loop why don't print mixed? Thanks and continue with your posts!!!
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).
Nice post!
thanks to you, I started to understand a little about arrays,but there is a point that I don't understand in the last example of your code when you want to add a property to the array using the type method: because as a final result it prints 0 , 1 , 2 ,nedy and not mixed? And in other for loop why don't print mixed? Thanks and continue with your posts!!!
Thanks @camicode . Please can you restructure your question, I do not quite understand it yet.
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