From:  jeffry killen <>
Date:  21 Sep 2009 05:58:08 Hong Kong Time

Does anyone want to take a stab at this?


I am working on a javascript object that produces an array of 
coordinates representing
a square grid.

I have test this in non object code and it works.
But the following code produces bad results:
Object constructor function code........
for(i = 0; i < size; i++) // group coordinate values as pairs to make 
cell origin coords
       this.tiles[i] = new Array();
        for(j = 0; j < size; j++)
               this.tiles[j] = new Array();
               this.tiles[j][0] = this.posLeft[j] + this.originLeft;    
// <<= x placement
               this.tiles[i][1] = this.posTop[i] + this.originTop;   // 
<<= y placement
               //tmp = this.tiles[i][1]+":"+this.tiles[j][0]; -> "NaN"
                // alernative syntax produces the same result
                //tmp = 
Math.toString(this.tiles[i][1])+":"+Math.toString(this.tiles[j][0]); -> 
                tmp = Math.toString(this.posTop[i] + 
this.originTop)+":"+Math.toString(this.posLeft[j] + this.originLeft);
                // each pair has to be immediately exported
                apush(this.pairs, tmp); // final list to export: apush() 
in another sourced js file

What is happening here; that does not happen in the non object code, is
when the multi dimensional array items are concatinated with ':', a math
operation is taking place and the result stored in this.pairs is NaN.
So, I am trying to coerce the data type to a string representation but 
what I
get is "[object:Math]:[Object:Math]"  instead:
not what I want; (for instance):

Can anyone suggest a fix?
Platform: Mac OSX 10.5x, Firefox 3.5.2
Thank you in advance

ps: I have written a php non OO version that also works.