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/javascript/reference/global_objects/null | |
| 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/javascript/reference/global_objects/null')
| -rw-r--r-- | files/ja/web/javascript/reference/global_objects/null/index.html | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/null/index.html b/files/ja/web/javascript/reference/global_objects/null/index.html new file mode 100644 index 0000000000..8bf9bb6522 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/null/index.html @@ -0,0 +1,76 @@ +--- +title: 'null' +slug: Web/JavaScript/Reference/Global_Objects/null +tags: + - JavaScript + - Language feature + - Literal + - Primitive +translation_of: Web/JavaScript/Reference/Global_Objects/null +--- +<div>{{jsSidebar("Objects")}}</div> + +<p><code>null</code> null という値は、意図的にオブジェクトの値が存在しないことを表します。これは JavaScript の<a href="/ja/docs/Glossary/Primitive">プリミティブ値</a>の 1 つであり、ブール演算では <a href="/ja/docs/Glossary/Falsy">falsy</a> として扱われます。</p> + +<div>{{EmbedInteractiveExample("pages/js/globalprops-null.html")}}</div> + + + +<h2 id="Syntax" name="Syntax">構文</h2> + +<pre class="syntaxbox notranslate"><code>null</code></pre> + +<h2 id="Description" name="Description">説明</h2> + +<p><code>null</code> 値は <code>null</code> というリテラルです。{{jsxref("Global_Objects/undefined","undefined")}} のようなグローバルオブジェクトのプロパティではありません。代わりに、 <code>null</code> は識別の欠如を表し、変数がオブジェクトを指してないことを示します。API においては、通常はオブジェクトが返されるところで、関連したオブジェクトがない場合に <code>null</code> がよく渡されます。</p> + +<pre class="syntaxbox notranslate">// foo が存在せず、定義も初期化もされていない場合: +foo; //ReferenceError: foo is not defined</pre> + +<pre class="syntaxbox notranslate">// foo が存在しているが、型も値も持たない場合: +var foo = null; +foo; //null +</pre> + +<h3 id="Difference_between_null_and_undefined" name="Difference_between_null_and_undefined"><code>null</code> と <code>undefined</code> の違い</h3> + +<p><code>null</code> か <code>undefined</code> をチェックする際は、<a href="/ja/docs/Web/JavaScript/Reference/Operators/Comparison_Operators">等価 (==) と 厳密等価 (===) 演算子の違い</a> に注意してください(前者では型変換が行われます)。</p> + +<pre class="brush: js notranslate">typeof null // "object" (歴史的な理由で "null" ではありません<code>) +typeof undefined // "undefined" +null === undefined // false +null == undefined // true +null === null // true +null == null // true +!null // true +isNaN(1 + null) // false +isNaN(1 + undefined) // true</code></pre> + +<h2 id="Specifications" name="Specifications">仕様</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">仕様書</th> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-null-value', 'null value')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザー実装状況</h2> + + + +<p>{{Compat("javascript.builtins.null")}}</p> + +<h2 id="See_also" name="See_also">関連情報</h2> + +<ul> + <li>{{jsxref("undefined")}}</li> + <li>{{jsxref("NaN")}}</li> + <li> + <p>{{jsxref("Operators/void", "void operator")}}</p> + </li> +</ul> |
