| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/API/console | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.
console . Window, WorkerGlobalScope . Window.console console .
console.log(" ");
: Web Worker .
console.assert()console.clear().
console.count().
console.countReset().
console.debug()debug .
console.dir()JavaScript . .
console.dirxml()XML/HTML , JavaScript .
console.error()console.exception() error() .
console.group()console.groupCollapsed()console.groupEnd()console.info()console.log()console.profile()(Firefox ) . .
console.profileEnd(). (Firefox ) .
console.table().
console.time()console.timeEnd()console.timeStamp() console.trace()console.warn() . , console.log(), console.info(), console.warn(), console.error() . , .
. , . , .
.
var someObject = { str: "Some text", id: 5 };
console.log(someObject);
.
[09:27:13.475] ({str:"Some text", id:5})
.
var car = "Dodge Charger";
var someObject = { str: "Some text", id: 5 };
console.info("My first car was a", car, ". The object is: ", someObject);
.
[09:28:22.711] My first car was a Dodge Charger. The object is: ({str:"Some text", id:5})
log() .
%o %OJavaScript . .
%d %i . . console.log("Foo %.2d", "1.1") 0 Foo 01 .
%s.
%f . . console.log("Foo %.2f", "1.1") Foo 1.10 .
: Chrome
. ...
for (var i = 0; i < 5; i++) {
console.log("Hello, %s. You've called me %d times.", "Bob", i + 1);
}
.
[13:14:13.481] Hello, Bob. You've called me 1 times.
[13:14:13.483] Hello, Bob. You've called me 2 times.
[13:14:13.485] Hello, Bob. You've called me 3 times.
[13:14:13.487] Hello, Bob. You've called me 4 times.
[13:14:13.488] Hello, Bob. You've called me 5 times.
"%c" CSS .
console.log(
"This is %cMy stylish message",
"color: yellow; font-style: italic; background-color: blue;padding: 2px",
);
, CSS .
"%c" .
console.log(
"Multiple styles: %cred %corange",
"color: red",
"color: orange",
"Additional unformatted message",
);
%c CSS . (Firefox , )
background .border .border-radiusbox-decoration-breakbox-shadowclear, floatcolorcursordisplayfont .line-heightmarginoutline .paddingtext-transform text-* .white-spaceword-spacing, word-breakwriting-mode :
. padding, margin display: inline-block .
. console.group() . console.groupCollapsed() , .
console.groupEnd() . ...
console.log("This is the outer level");
console.group("First group");
console.log("In the first group");
console.group("Second group");
console.log("In the second group");
console.warn("Still in the second group");
console.groupEnd();
console.log("Back to the first group");
console.groupEnd();
console.debug("Back to the outer level");
.
[Demo of nested groups in Firefox console]
. console.time() . . , console.timeEnd() . , .
...
console.time("answer time");
alert("Click to continue");
console.timeLog("answer time");
alert("Do a bunch of other stuff...");
console.timeEnd("answer time");
, , .
.
: , . , .
. console.trace() . ...
function foo() {
function bar() {
console.trace();
}
bar();
}
foo();
.
| Specification |
|---|
| Console # console-namespace |
console Firefox .This page was last modified on 2024 12 17 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |