반응형
Chrome 콘솔에서 전체 개체를 표시하는 방법
var functor=function(){
//test
}
functor.prop=1;
console.log(functor);
이것은 단지 펑터의 기능 부분을 보여줄 뿐이고, 콘솔에서 펑터의 속성을 보여줄 수 없습니다.
사용하다console.dir()
검색 가능한 개체를 출력하려면 대신 클릭할 수 있습니다..toString()
버전, 다음과 같습니다.
console.dir(functor);
지정한 개체의 JavaScript 표현을 인쇄합니다.기록 중인 개체가 HTML 요소인 경우 해당 DOM 표현의 속성이 인쇄됩니다.
[1] https://developers.google.com/web/tools/chrome-devtools/debug/console/console-reference#dir
다음을 시도하면 더 나은 결과를 얻을 수 있습니다.
console.log(JSON.stringify(functor));
다음을 시도하면 훨씬 더 좋은 결과를 얻을 수 있습니다.
console.log(JSON.stringify(obj, null, 4));
var gandalf = {
"real name": "Gandalf",
"age (est)": 11000,
"race": "Maia",
"haveRetirementPlan": true,
"aliases": [
"Greyhame",
"Stormcrow",
"Mithrandir",
"Gandalf the Grey",
"Gandalf the White"
]
};
//to console log object, we cannot use console.log("Object gandalf: " + gandalf);
console.log("Object gandalf: ");
//this will show object gandalf ONLY in Google Chrome NOT in IE
console.log(gandalf);
//this will show object gandalf IN ALL BROWSERS!
console.log(JSON.stringify(gandalf));
//this will show object gandalf IN ALL BROWSERS! with beautiful indent
console.log(JSON.stringify(gandalf, null, 4));
내겐 완벽하게 효과가 있었어요
for(a in array)console.log(array[a])
추출된 데이터의 정리 및 사후 사용을 찾기 위해 콘솔에서 생성된 배열을 추출할 수 있습니다.
나는 트라이던트 D'Gao 답변의 기능을 만들었습니다.
function print(obj) {
console.log(JSON.stringify(obj, null, 4));
}
사용방법
print(obj);
콘솔에 편리하게 인쇄할 수 있는 기능을 작성했습니다.
// function for debugging stuff
function print(...x) {
console.log(JSON.stringify(x,null,4));
}
// how to call it
let obj = { a: 1, b: [2,3] };
print('hello',123,obj);
콘솔로 출력됩니다.
[
"hello",
123,
{
"a": 1,
"b": [
2,
3
]
}
]
최신 브라우저를 통해,console.log(functor)
완벽하게 작동합니다. (behaves도 마찬가지였습니다.console.dir
).
또 다른 방법은 함수를 배열로 래핑하는 것입니다.
console.log( [functor] );
언급URL : https://stackoverflow.com/questions/4482950/how-to-show-full-object-in-chrome-console
반응형
'prosource' 카테고리의 다른 글
내장된 C에 sprintf()가 있는 Float 사용 (0) | 2023.10.25 |
---|---|
테이블에서 Oracle 랜덤 행 (0) | 2023.10.25 |
파이썬에 불변 리스트가 있습니까? (0) | 2023.10.25 |
NoSuch Bean 정의란?예외 사항 및 수정 방법은 무엇입니까? (0) | 2023.10.25 |
wp_signon()을 사용하여 워드프레스의 사용자 테이블 이외의 데이터를 사용하여 로그인하는 방법? (0) | 2023.10.25 |