This article mainly introduces the use of Nodejs to implement PHP Print_r function code, the need for friends can refer to the following
Code as follows: function ergodic (obj,indentation) { var indent = " " + indentation; if (Obj.constructor = = Array | | Obj.constructor = = Object { for (var p in obj) { if (obj[p].constructor = = array| | Obj[p].constructor = = Object) { Console.log (indent + "[" +p+ "] =>" +typeof (obj) + ""); Console.log (indent + "{"); ergodic (Obj[p], indent); Console.log (indent + "}"); } else if (Obj[p].constructor = = String) { Console.log (indent + "[" +p+ "] => ' "+obj[p]+" "); } else { Console.log (indent + "[+p+"] => "+obj[p]+"); } } } { function print_r (obj) { Console.log ("{") ergodic (obj, ""); Console.log ("}")} var stu = {' name ': ' Alan ', ' Grade ': {' Chinese ': #, ' Math ':130, ' competition ': {' NOI ': ' The ' the ' the ' the ' the ' the ' the ' the ' '; Print_r (STU);