Console API

Console API는 코드의 특정 지점에서 값이나 변수를 기록하고, 작업의 소요 시간을 알아내는 등 개발자가 사용할 수 있는 디버깅 기능을 제공합니다.

개념과 사용법

Console API는 사유 API로 시작하였으며, 브라우저가 각자 다른 구현을 했습니다. 이후 Console API 명세가 만들어져 일관적인 동작 방식을 정의하였으며, 결국 모든 최신 브라우저가 같은 동작을 따르게 되었습니다. 그러나 일부 구현체는 여전히 자신만의 사유 함수를 가지고 있습니다. 다음 링크에서 알아보세요.

사용은 매우 간단합니다. Window.console, 워커에서는 WorkerGlobalScope.console, 아니면 그냥 console로 접근 가능한 console 객체는 브라우저의 웹 콘솔에 값을 기록하는 등 기초적인 디버깅 작업에 사용할 수 있는 메서드를 제공합니다.

가장 자주 쓰이는 메서드는 console.log()이며, 변수의 값을 기록할 때 사용합니다.

인터페이스

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

예제

let myString = 'Hello world';

// Output "Hello world" to the console
console.log(myString);

console 문서의 예제 항목에서 더 많은 예제를 확인하세요.

명세

Specification Status Comment
Console API Living Standard Initial definition.

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
ConsoleChrome Full support 1Edge Full support 12Firefox Full support 2IE Full support 8
Notes
Full support 8
Notes
Notes In Internet Explorer 8 and 9, the console object is undefined when the developer tools are not open. This behavior was fixed in Internet Explorer 10.
Opera Full support 10.5Safari Full support 3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 1Samsung Internet Android Full support 1.0
assertChrome Full support 1Edge Full support 12Firefox Full support 28IE Full support 8Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 28Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
clearChrome Full support YesEdge Full support 12Firefox Full support 48IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 48Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
countChrome Full support YesEdge Full support 12Firefox Full support 30IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 30Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
countResetChrome Full support YesEdge Full support ≤79Firefox Full support 62IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 62Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
debugChrome Full support YesEdge Full support 12Firefox Full support 4IE Full support YesOpera ? Safari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
dir
Experimental
Chrome Full support 1Edge Full support 12Firefox Full support 8IE Full support 9Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 8Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
dirxml
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android No support NoOpera Android ? Safari iOS ? Samsung Internet Android Full support Yes
errorChrome Full support 1Edge Full support 12Firefox Full support 4IE Full support 8Opera Full support 10.5Safari Full support 3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 1Samsung Internet Android Full support 1.0
exception (an alias for error)
DeprecatedNon-standard
Chrome No support NoEdge No support 13 — 79Firefox Full support 28IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android Full support 28Opera Android ? Safari iOS No support NoSamsung Internet Android No support No
groupChrome Full support 1Edge Full support 12Firefox Full support 4IE Full support 11Opera Full support YesSafari Full support 4WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android Full support 1.0
groupCollapsedChrome Full support 6Edge Full support 12Firefox Full support 52IE Full support 11Opera ? Safari Full support 5.1WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 52Opera Android ? Safari iOS ? Samsung Internet Android Full support 1.0
groupEndChrome Full support 1Edge Full support 12Firefox Full support 9IE Full support 11Opera Full support YesSafari Full support 4WebView Android Full support 37Chrome Android Full support 18Firefox Android Full support 9Opera Android ? Safari iOS ? Samsung Internet Android Full support 1.0
infoChrome Full support YesEdge Full support 12Firefox Full support 4IE Full support 8Opera Full support YesSafari Full support Yes
Notes
Full support Yes
Notes
Notes No information icon
WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
logChrome Full support 1Edge Full support 12Firefox Full support 4IE Full support 8Opera Full support 10.5Safari Full support 3WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 11Safari iOS Full support 1Samsung Internet Android Full support 1.0
profile
ExperimentalNon-standard
Chrome Full support 53Edge Full support 12Firefox Full support YesIE Full support YesOpera ? Safari ? WebView Android Full support 53Chrome Android Full support 53Firefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android Full support 6.0
profileEnd
ExperimentalNon-standard
Chrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera ? Safari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
tableChrome Full support 27Edge Full support 13Firefox Full support 34IE No support NoOpera Full support 11Safari Full support 6.1WebView Android Full support ≤37Chrome Android Full support 27Firefox Android Full support 34Opera Android Full support 11Safari iOS Full support 7Samsung Internet Android Full support 1.5
timeChrome Full support 1Edge Full support 12Firefox Full support 10IE Full support 11Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 10Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
timeEndChrome Full support 1Edge Full support 12Firefox Full support 10IE Full support 11Opera Full support YesSafari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android Full support 1.0
timeLogChrome Full support 72Edge Full support 79Firefox Full support 62IE No support NoOpera Full support 60Safari No support No
Notes
No support No
Notes
Notes See bug 186833.
WebView Android Full support 72Chrome Android Full support 72Firefox Android Full support 62Opera Android ? Safari iOS No support NoSamsung Internet Android No support No
timestamp
ExperimentalNon-standard
Chrome Full support YesEdge Full support 12Firefox Full support YesIE Full support 11Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 10Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
traceChrome Full support 1Edge Full support 12Firefox Full support 10IE Full support 11Opera Full support 11Safari Full support 4WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 10Opera Android Full support 11Safari iOS Full support 3.2Samsung Internet Android Full support 1.0
warnChrome Full support YesEdge Full support 12Firefox Full support 4IE Full support 8Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes
Available in workersChrome Full support YesEdge Full support 12Firefox Full support 38IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 38Opera Android ? Safari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.

같이 보기