4.1.2 Multidimensional Arrays
An array can also be nested as an element of an array. When accessing the elements of a multidimensional array, you can use the [ ] operator consecutively. In the following example, “arr_y” is a two-dimensional array. (1)
arr_y[1] is an array of elements of index 1, namely ["abc", "jqk", "xyz"], and it is assigned to the new variable “arr_x.” (2)
So, arr_x[1] is "jqk", and arr_y[1][2] is "xyz" because it points to [2] of arr_y[1].
0001.job
var arr_y = [ [10,20], ["abc","jqk", "xyz"] ] # (1)
var arr_x=arr_y[1] # (2)
print arr_x[1]
print arr_y[1][2]
Result
jqk
xyz
Last updated
Was this helpful?