<div class="codetitle"> <span><a style="CURSOR: pointer" data="98386" class="copybut" id="copybut98386" onclick="doCopy('code98386')"><u>코드 복사</u></a></span> 코드는 다음과 같습니다.</div> <div class="codebody" id="code98386"> <br><script type="text/javascript"> <br> <!-- <BR>var my={ <BR>str:'', <BR>deep:0, <BR>block:' ', <BR>get_pre:function(n) <BR> { <BR>pre=''; <BR>for(i=0;i<n;i ) <BR>{ <BR>pre =this.block; <BR>return pre; }, <BR>show_obj:function(obj) <BR>{ <BR>for(k in obj) <BR>{ <BR>if(typeof(obj[k])!='객체' && typeof(obj[ k]) !='배열') <BR>{ <BR>pre=this.get_pre(this.deep) <BR>this.str =pre k '=>' obj[k] 'n'; 🎜>} <br>else if(typeof(obj[k])=='object' && typeof(obj[k].length)=='undefine')//객체인 경우<br>{ <br>pre=this.get_pre(this.deep); <br>this.str =pre k '=>OBJECT{n'; <br>this.deep ;//재귀 시작, 깊이 1 <br>this.show_obj (obj[k] ); <br>pre = this.get_pre(this.deep); <br>this.deep--;//재귀는 -1의 깊이로 끝납니다. <br>this.str =pre ' }n'; <br>} <br>else if(typeof(obj[k])=='object' && typeof(obj[k].length)!='undefine')//배열인 경우<br>{ <br>pre=this.get_pre(this.deep); <br>this.str =pre k '=>ARRAY[n'; <br>this.deep ;//동일 객체<br> .show_obj(obj[k]); <br>pre = this.get_pre(this.deep); <br>this.deep--;//동일 객체<br>this.str =pre ']n'; 🎜>} <br>} <br> return this.str; <br>}, <br>alert_obj:function(obj) <br>{ <br>alert(this.show_obj(obj)) <br>} <br>} <br>my.alert_obj( {a:{b:{c:{d:'hello world'}}}}) <br>//-> <br></script> 🎜><br> <br>chrome OK console.log를 사용하면 <br>즉,</div>