Array of arrays in javascript -
is following correct in javascript:
var candidates = []; candidates.push(["rand","paul"]); candidates.push(["hillary","clinton"]);
where each element in a
array of 2 strings.
i pushing a
in loop.
additionally can iterate on array follows:
for(var candidate in candidates) { var first_name = candidate[0]; }
you should not use in arrays! if array prototype extended run through new functions there keys.
you should do:
var i, first_name; for( = 0; < candidates.length; i++ ) { first_name = candidates[i][0]; }
Comments
Post a Comment