I\'d like to represent 2d cartesian cordinates in a 2d JS array. The 2d space is of indeterminate size (can extend into -x and -y space too). This is fine for positive x a
Are you sure you need negative indizes? Usually every coordinate system for computer graphics starts at (0/0) in the upper left screen corner. And they draw their axes somewhere else.
So, the solution for a finite size is just transforming the coordinates. Also, you can use negative indizes on Arrays, but better call that "keys on array Objects". If you know their limitations, you can use them:
But, you say your space is indeterminate. The problem is just that there is no inifinite data structure - in no programming language. Of course array indizes could get very big, but do you really need them? I'm very sure that a twodimensional array with a size of (2^32)^2 is nothing but a huge waste of memory space - or at least something that makes your application extremely slow.
It might be better to think of a one-dimensional array with objects representing points in. You can easily loop over it, you can have any number for coordinate values and they don't need that much memory.