How do you create a 3d array

I’d like to make an array like array [ x][y][z]
I gave a look to the link below, but I still don’t know to make the 3d array

In JavaScript, you can create a 3D array by creating an array of arrays of arrays, like so:

var my3dArray = [  [ [1, 2], [3, 4] ],
  [ [5, 6], [7, 8] ],
  [ [9, 10], [11, 12] ]
];

In the example above, my3dArray is a 3D array that contains 3 arrays, each of which contains 2 arrays, each of which contains 2 numbers.

You can access individual elements in the 3D array using multiple indexes, like so:

console.log(my3dArray[1][0][1]); // Output: 6

In the example above, we’re accessing the element at index 1 of the outer array, which gives us the second sub-array. Then we’re accessing the element at index 0 of that sub-array, which gives us the first sub-array within the second sub-array. Finally, we’re accessing the element at index 1 of that sub-array, which gives us the number 6.

1 Like

Hi ulrich, thank you for the answer. However I got an error
I typed like below and it says console is not defined
{
“Command”: “executeScript_Sandbox”,
“Target”: “var my3dArray = [ [ [1, 2], [3, 4] ], [ [5, 6], [7, 8] ], [ [9, 10], [11, 12] ]];”,
“Value”: “3d”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “console.log(my3dArray[1][0][1]);”,
“Value”: “”,
“Description”: “”
}

<<<I typed again like below, but I get ‘Cannot read property ‘0’ of undefined’ error>>>>

{
“Command”: “executeScript_Sandbox”,
“Target”: “var my3dArray = [ [ [1, 2], [3, 4] ], [ [5, 6], [7, 8] ], [ [9, 10], [11, 12] ]]; return my3dArray\n”,
“Value”: “my3dArray”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return ${my3dArray}[0][0][0];”,
“Value”: “my3dArray”,
“Description”: “”
}

Hmm, maybe Ui.Vision itself does not support 3D arrays. So you can use 3D arrays only within the executeScript_Sandbox command, but can not assign it to a Ui.Vision variables.

2D arrays work fine. But I actually never used 3D arrays in RPA.

1 Like

Thank you for your time. At least now I don’t need to struggle with it.