From:  jeffry killen <jekillen@prodigy.net>
Date:  21 Sep 2009 05:58:08 Hong Kong Time
Newsgroup:  news.mozilla.org/mozilla.dev.web-development
Subject:  

Does anyone want to take a stab at this?

NNTP-Posting-Host:  63.245.208.166

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]); -> 
"[object:Math]:[Object:Math]"
                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):
"10:10"
"10:25"
"10:40"
"25:10"
"25:25"
"25:40"
"40:10"
"40:25"
"40:40"

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

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