I was playing a bit with javascript and I found out (at least for me) strange behaviors when multi-dimensional arrays Works with a foreach loop, so I have this piece of code:
Output is:
First: 0 undefined 1 undefined second: abcd I hope first And the second will be the same. Can you please tell me what am I missing?
Note: Please do not advise to override the array via jQuery, or somehow I do not have coding problems, I am curious about this particular situation. Thanks!
Eric Mickelson was told some good points, but he did so. <<<>
<...> (... in ...) loop iterators on object properties array in javascript An object is that you can iterate over an array with it but it will be slow and it is not normally recommended (see) The fact is that the iterative meanings on properties rather than values, This array gives indexes instead of values (it can be helpful when it is helpful to arrays) The question The solution can be solved with the for loop :
var Third = ''; (For array in var arrayIndex) {third + = '' + arr [arrayIndex] [0] + '' arr [arrayIndex] [1]; } For associative array example (... in ...) the loop will be easy: Var person = []; Person ["id"] = 1; Person ["birth"] = 200 9; Person ["favorite-mi"] = "chicken"; Var fourth = ''; (Var array indices in person) {fourth + = '' + person [array index]; }
Comments
Post a Comment