Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 923521 of Console.log()

  • URL ревизии: Web/API/Console/log
  • Заголовок ревизии: Console.log()
  • ID ревизии: 923521
  • Создано:
  • Автор: alfill
  • Это текущая ревизия? Нет
  • Комментарий

Содержание ревизии

{{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

Источник ревизии

<div>{{APIRef("Console API")}}{{Non-standard_header}}</div>

<p>Выводит сообщения ввеб-консоль.</p>

<p>{{AvailableInWorkers}}</p>

<h2 id="Syntax">Синтакс</h2>

<pre class="syntaxbox">
console.log(<em>obj1</em> [, <em>obj2</em>, ..., <em>objN</em>]);
console.log(<em>msg</em> [, <em>subst1</em>, ..., <em>substN</em>]);
</pre>

<h2 id="Parameters">Параметры</h2>

<dl>
 <dt><code>obj1</code> ... <code>objN</code></dt>
 <dd>A list of JavaScript objects to output. The string representations of each of these objects are appended together in the order listed and output.</dd>
 <dt><code>msg</code></dt>
 <dd>A JavaScript string containing zero or more substitution strings.</dd>
 <dt><code>subst1</code> ... <code>substN</code></dt>
 <dd>JavaScript objects with which to replace substitution strings within <code>msg</code>. This gives you additional control over the format of the output.</dd>
</dl>

<p>See <a href="/en-US/docs/DOM/console#Outputting_text_to_the_console">Outputting text to the console</a> in the documentation of {{domxref("console")}} for details.</p>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("Console API", "#consolelogobject--object-", "console.log()")}}</td>
   <td>{{Spec2("Console API")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoDesktop("2.0")}}</td>
   <td>8</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td>Substitution strings</td>
   <td>{{CompatVersionUnknown}}<br />
    {{CompatChrome(28)}}<sup>[1]</sup></td>
   <td>{{CompatGeckoDesktop("9.0")}}</td>
   <td>10<sup>[2]</sup></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td>Available in workers</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("38.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("2.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td>Substitution strings</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("9.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td>Available in workers</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("38.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] If a negative value is passed to <code>%d</code>, it will be rounded down to the closest negative integer, so -0.1 becomes -1.</p>

<p>[2] <code>%c</code> is not supported, <code>%d</code> will render as 0 when it is not a number.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li><a class="external" href="https://www.opera.com/dragonfly/documentation/console/">Opera Dragonfly documentation: Console</a></li>
 <li><a class="external" href="https://msdn.microsoft.com/library/gg589530">MSDN: Using the F12 Tools Console to View Errors and Status</a></li>
 <li><a href="https://getfirebug.com/wiki/index.php/Console_API">Firebug wiki: Console API</a> - Firebug supports additional features in its console.log() implementation, such as <a href="https://www.softwareishard.com/blog/firebug/firebug-tip-styled-logging/">styled logging</a>.</li>
 <li><a href="https://nodejs.org/docs/latest/api/console.html#console_console_log_data">NodeJS: Console API</a></li>
</ul>
Вернуть эту версию