{{APIRef("Console API")}}{{Non-standard_header}}
Выводит сообщения ввеб-консоль.
{{AvailableInWorkers}}
Синтакс
console.log(obj1 [, obj2, ..., objN]); console.log(msg [, subst1, ..., substN]);
Параметры
obj1
...objN
- A list of JavaScript objects to output. The string representations of each of these objects are appended together in the order listed and output.
msg
- A JavaScript string containing zero or more substitution strings.
subst1
...substN
- JavaScript objects with which to replace substitution strings within
msg
. This gives you additional control over the format of the output.
See Outputting text to the console in the documentation of {{domxref("console")}} for details.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName("Console API", "#consolelogobject--object-", "console.log()")}} | {{Spec2("Console API")}} | Initial definition |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("2.0")}} | 8 | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Substitution strings | {{CompatVersionUnknown}} {{CompatChrome(28)}}[1] |
{{CompatGeckoDesktop("9.0")}} | 10[2] | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Available in workers | {{CompatUnknown}} | {{CompatGeckoDesktop("38.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | {{CompatGeckoMobile("2.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Substitution strings | {{CompatUnknown}} | {{CompatGeckoMobile("9.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Available in workers | {{CompatUnknown}} | {{CompatGeckoMobile("38.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] If a negative value is passed to %d
, it will be rounded down to the closest negative integer, so -0.1 becomes -1.
[2] %c
is not supported, %d
will render as 0 when it is not a number.
See also
- Opera Dragonfly documentation: Console
- MSDN: Using the F12 Tools Console to View Errors and Status
- Firebug wiki: Console API - Firebug supports additional features in its console.log() implementation, such as styled logging.
- NodeJS: Console API