diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
| commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
| tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/console/count | |
| parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
| download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip | |
initial commit
Diffstat (limited to 'files/ja/web/api/console/count')
| -rw-r--r-- | files/ja/web/api/console/count/index.html | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/files/ja/web/api/console/count/index.html b/files/ja/web/api/console/count/index.html new file mode 100644 index 0000000000..d0c7659d14 --- /dev/null +++ b/files/ja/web/api/console/count/index.html @@ -0,0 +1,106 @@ +--- +title: Console.count() +slug: Web/API/console/count +tags: + - API + - DOM + - Debugging + - Method + - NeedsBrowserCompatibility + - Web Development + - web console +translation_of: Web/API/Console/count +--- +<div>{{APIRef("Console API")}}</div> + +<p><strong><code>console.count()</code></strong> は<code>count()</code> を個々に呼び出した回数を記録します。</p> + +<p>{{AvailableInWorkers}}</p> + +<h2 id="構文">構文</h2> + +<pre class="syntaxbox notranslate">console.count(<var>[label]</var>);</pre> + +<h3 id="引数">引数</h3> + +<dl> + <dt><code>label</code> {{Optional_Inline}}</dt> + <dd>{{jsxref("String")}}。<code>label</code> を与えると、この関数は特定のラベルを伴って <code>count()</code> を呼び出した回数を記録します。<code>label</code> を省略すると、この関数は<code>default</code>というラベルを伴って <code>count()</code> を呼び出したかのように振る舞います</dd> +</dl> + +<h2 id="Examples">Examples</h2> + +<p>例えば、以下のコードについて考えます:</p> + +<pre class="brush: js notranslate">let user = ""; + +function greet() { + console.count(); + return "hi " + user; +} + +user = "bob"; +greet(); +user = "alice"; +greet(); +greet(); +console.count();</pre> + +<p>コンソールの出力は、以下のようになります:</p> + +<pre class="brush: none; notranslate">"default: 1" +"default: 2" +"default: 3" +"default: 4"</pre> + +<p>特にラベルが指定されなかったので表示されているラベルは <code>default</code> となっています。</p> + +<p>始めの <code>count()</code> で引数 <code>label</code> に変数 <code>user</code> を、また 2 番目の <code>count()</code> で文字列 "alice" を与えました:</p> + +<pre class="brush: js notranslate">let user = ""; + +function greet() { + console.count(user); + return "hi " + user; +} + +user = "bob"; +greet(); +user = "alice"; +greet(); +greet(); +console.count("alice");</pre> + +<p>すると、以下のように出力されます:</p> + +<pre class="notranslate">"bob: 1" +"alice: 1" +"alice: 2" +"alice: 3"</pre> + +<p><code>label</code> の値のみに基づいて、個々の呼び出し回数を管理しています。</p> + +<h2 id="Specifications" name="Specifications">仕様</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">仕様書</th> + <th scope="col">策定状況</th> + <th scope="col">コメント</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("Console API", "#count", "console.count()")}}</td> + <td>{{Spec2("Console API")}}</td> + <td>最初期の定義</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザ実装状況</h2> + + + +<p>{{Compat("api.Console.count")}}</p> |
