hi,

i was about to leave a message on the "Improving the Array class" thread when this forum asked me to consider to open a new one because this thread was "more than 29 months old" :

http://www.sitepoint.com/forums/show...tpost&t=131995

it's about the Array.prototype.getDebugString method used by the Array.prototype.print_r method on this post :

i tried :
Code:
    var n5 = [1, 2, 3];
    n5.print_r();
i got :
Code:
Array
(
	[0] => 1
	[1] => 10
	[2] => 11
)
as u can see, the numbers are shown as binaries by print_r... don't know why...

so i modified the method like that :
Code:
Array.prototype.getDebugString = function ( numTabs )
  {
	// We subract one from numTabs here and add two later because of an odd illegal radix error
	numTabs	= ( typeof numTabs == 'undefined' ) ? 0 : numTabs - 1;
	var i, l = this.length, tabs = ('\t').replicate( numTabs ), output = 'Array\n' + tabs + '(\n', o = {};
	for ( i = 0; i < l; i++ )
	  {
	  output += tabs + '\t[' + i + '] => ';
	  o = this[i];
	  // for decimal notation
	  if ( typeof o == 'number' && isFinite ( o ) )
	    o = o.toString ( 10 ); 
	  output += o.getDebugString ( numTabs + 2 ) + '\n';
	  }
	delete o;
	return output + tabs + ')\n';
}
If any one like (as i do !) to use this print_r method for JS debug, it may be useful...