+= doesn't work with a 2d array in JS

In a JS I am using 2d arrays. The following works just fine

infastructure[1,i]=infastructure[1,i]+desire_*popChange;_

However, if I try this:
infastructure[1,i]+=desire_popChange;_
I get the following error:
_
> Internal compiler error. See the*_
> console log for more information.
> output was:BCE0051: Operator ‘+’
> cannot be used with a left hand side
> of type ‘error’ and a right hand side
> of type ‘float’.
And the console does not even seem to be able to identify where in the code the error is arising.
Throwing in a debug line before the offending line shows that infastructure[1,i] is properly declared by that point and has a float value in it and that I am not going out of bounds or anything like that.
I have tried a couple different ways of declaring the array including:
var infastructure : float[,] = new float[8,10];
and
var infastructure = new float[8,10];
But no dice.
I figure that the error has to do with JS’s typing of variables or something equally annoying. Obviously this isn’t a game stopper as I can just avoid using += statements, but it is annoying and right now I am a bit of a loss in regards to getting the darn thing to work.

This is a truly strange one!

Before I go any further, it is important to note that the type of array you are using is not native to JS. It’s actually a Unity3D tack-on! (From C# .NET, SEE: [Multidimensional Arrays - C# Programming Guide | Microsoft Learn][1] ) So, right here you may be running into issues.

This stated, it may be possible that that type of array simply does not support the += operation (It’s hard to say, I’ve tried to stay away from using it). You may want to try float, as opposed to float[,]

Assuming this is not true, it seems to be treating your + and your = as seperate operators.

Try: infastructure[1,i] += desire_*popChange; (note that the += is surrounded by spaces)_
To further specify to the compiler that you are NOT using + separately from the =, you could try
(infastructure[1,i]) += (desire_popChange); This isolates the += from either of your statements._
Honestly, I have never played with this type of array, so it is all speculation.
Other alternatives you could consider are:
var arr = new Array();
arr.push(new Array());
Now, this next one is tricky, and I have no idea if it will work. I’ve long dropped JS for C#, but theoretically it could work:
var arr : ArrayList = new ArrayList;
You will want to import System.Collections for this to work!
_
[1]: Microsoft Learn: Build skills that open doors in your career