Return to Snippet

Revision: 2750
at April 12, 2007 07:37 by frankyfish


Initial Code
print_r = function(theObj,indent){
	var output=String(theObj)+"\n";
	if (indent == undefined) { indent = "    "; } else { indent += "    "; }
	if(theObj.constructor == Array || theObj.constructor == Object) {
		for(var p in theObj){
			if(theObj[p].constructor == Array|| theObj[p].constructor == Object){
				var type = (theObj[p].constructor == Array) ? "Array" : "Object";
				output += indent+"["+p+"]("+type+")=>\n";
				output += print_r(theObj[p],indent);
			} else { output += indent+"["+p+"]:"+theObj[p]+"\n"; }
		}
	}
	trace(output);
}

Initial URL

                                

Initial Description

                                

Initial Title
actionscript print_r

Initial Tags

                                

Initial Language
ActionScript