Console API

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Console API는 개발자가 코드의 설정 지점에서 메시지나 변수 값을 로깅 하거나, 작업 완료에 걸리는 시간을 측정하는 등의 디버깅 작업을 수행할 수 있는 기능을 제공합니다.

참고 : 이 기능은 Web Worker에서 사용할 수 있습니다.

개념 및 사용법

Console API는 처음에는 대부분 자체 개발 API로 시작되었으며, 브라우저마다 구현 방식이 다르고 일관성이 없었습니다. 콘솔 API 명세는 일관된 동작을 정의하기 위해 만들어졌으며, 모든 최신 브라우저는 결국 일관된 동작을 구현하기로 했지만, 일부 구현에는 여전히 자체적인 추가 함수가 있습니다. 여기에서 자세히 알아보세요.

사용법은 매우 간단합니다. the console 객체에는 일반적으로 브라우저의 웹 콘솔에 다양한 값을 로깅 하는 데 중점을 두고 있고, 기초적인 디버깅 작업을 수행하기 위해 호출할 수 있는 많은 메서드가 포함되어 있습니다.

가장 일반적으로 사용되는 메서드는 console.log이며, 특정 변수 안에 포함된 현재 값을 기록하는 데 사용됩니다.

인터페이스

console

로깅, 스택 추적, 타이머, 카운터 등 기초적인 디버깅 기능을 제공합니다.

예제

js
let myString = "Hello world";

// 콘솔에 "Hello world"가 출력됩니다
console.log(myString);

더 많은 예제는 console 문서를 참조하세요.

명세

Specification
Console
# console-namespace

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
console
assert() static method
clear() static method
countReset() static method
count() static method
debug() static method
dir() static method
options.colors parameter
ExperimentalNon-standard
options.depth parameter
ExperimentalNon-standard
options.showHidden parameter
ExperimentalNon-standard
dirxml() static method
error() static method
exception() static method (an alias for error())
DeprecatedNon-standard
groupCollapsed() static method
groupEnd() static method
group() static method
info() static method
log() static method
profileEnd() static method
Non-standard
profile() static method
Non-standard
Substitution strings
table() static method
timeEnd() static method
timeLog() static method
timeStamp() static method
Non-standard
time() static method
trace() static method
warn() static method
Available in workers

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.
User must explicitly enable this feature.
Has more compatibility info.

같이 보기

  • Tools
  • Web Console — Firefox의 웹 콘솔이 콘솔 API 호출을 처리하는 방법
  • about:debugging — 디버깅 대상이 모바일 디바이스인 경우 콘솔 출력을 확인하는 방법