This isn't a traditional multi-dimensional array. For example arrA[2][1]
in my example below will give you o
the second letter of John
not an index into a second array.
Instead you have an array that has multiple elements, one of which is an array object. To access test2
you would use arrA[4][1]
. See this fiddle.
var arrA = ['Jennifer','Jessica','John','Peter'];
var arrB = ['test1','test2','test3','test4'];
arrA.push(arrB);
arrA.push('fred');
console.log(arrA);
console.log(arrA[4][1]);
console.log(arrA[5]);
console.log(arrA[2][1]);
The output will be the array then test2
then fred
, then o
.
This makes a it a bit tricky when you traverse the array in a generic manner, you will need to check whether you are dealing with a string or a string array. Was you intention a multi-dim array or a collection of objects some which are strings and some which are string arrays?