Return to Snippet

Revision: 2751
at April 12, 2007 07:39 by frankyfish


Initial Code
function print_r(theObj){
	  if(theObj.constructor == Array ||
	     theObj.constructor == Object){
	    document.write("<ul>");
	    for(var p in theObj){
	      if(theObj[p].constructor == Array||
	         theObj[p].constructor == Object){
	document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
	        document.write("<ul>");
	        print_r(theObj[p]);
	        document.write("</ul>");
	      } else {
	document.write("<li>["+p+"] => "+theObj[p]+"</li>");
	      }
	    }
	    document.write("</ul>");
	  }
	}

Initial URL

                                

Initial Description

                                

Initial Title
javascript print_r

Initial Tags

                                

Initial Language
JavaScript