Defining 2 dimenstional arrays

I am trying to create a large 2 dimensional array in java script and am experiencing an error.
var arr:int[,] = new int[5,5];

arr=[[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5],
[1,2,3,4,5]];

var someVariable = arr[1][4];

The error it returns is for the arr= line, and it says: BCE0022: Cannot convert ‘int’ to ‘int[,]’.

if i define the array using lines like:

var someVariable = arr[1,2];

it works fine, but if I define each value individually on my current project, it would take over 4000 lines, so that’s not an option. how can I create an array in java script that allows me define hte array all at once in a table, instead of line by line?

I don’t know if Unityscript has any syntax to supply 2D arrays with initial values when declaring them; what you’re using is the syntax for jagged arrays. You can define a 1D array with initial values and then convert to a 2D array with a little code, or you might just leave it as a 1D array and emulate a 2D array with a bit of math. i.e.,

arr[3, 4]

would be written as (assuming a “columns” variable which is of course the number of columns in the array):

arr[3 + 4*columns]

Although uglier code, it’s actually somewhat faster than a 2D array.