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 785283 of Object.is()

  • リビジョンの URL スラグ: Web/JavaScript/Reference/Global_Objects/Object/is
  • リビジョンのタイトル: Object.is()
  • リビジョンの ID: 785283
  • 作成日:
  • 作成者: teoli
  • 現行リビジョン? いいえ
  • コメント + sidebar

このリビジョンの内容

{{JSRef("Global_Objects", "Object")}} {{harmony}}

概要

渡された 2 つの値が本当に同じかどうかを確認します。

構文

Object.is(value1, value2)

引数

value1
value2
これら 2 つの値を比較します。

説明

同値演算子 (===) による比較とほぼ同じですが、次の 2 点のみ戻り値が異なります。

  • NanNaN の比較結果
  • +0-0 の比較結果

Object.is("foo", "foo");     // true
Object.is(window, window);   // true

Object.is("foo", "bar");     // false
Object.is([], []);           // false

// 同値演算子と戻り値が異なるケース
Object.is(0, -0);            // false
Object.is(NaN, 0/0);         // true

ブラウザ実装状況

{{CompatibilityTable}}
機能 Chrome Firefox (Gecko) Internet Explorer Opera Safari
基本サポート ? {{CompatGeckoDesktop("22")}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
機能 Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
基本サポート {{CompatNo}} {{CompatGeckoDesktop("22")}} {{CompatNo}} {{CompatNo}} {{CompatNo}}

このリビジョンのソースコード

<div>
<div>{{JSRef("Global_Objects", "Object")}} {{harmony}}</div>
</div>

<h2 id="Summary" name="Summary">概要</h2>

<p>渡された 2 つの値が本当に同じかどうかを確認します。</p>

<h2 id="Syntax" name="Syntax">構文</h2>

<pre class="syntaxbox">
Object.is(<var>value1</var>, <var>value2</var>)</pre>

<h3 id="Parameters" name="Parameters">引数</h3>

<dl>
 <dt><var>value1</var></dt>
 <dt><var>value2</var></dt>
 <dd>これら 2 つの値を比較します。</dd>
</dl>

<h2 id="Description" name="Description">説明</h2>

<p>同値演算子 (<code>===</code>) による比較とほぼ同じですが、次の 2 点のみ戻り値が異なります。</p>

<ul>
 <li><code>Nan</code> と <code>NaN</code> の比較結果</li>
 <li><code>+0</code> と <code>-0</code> の比較結果</li>
</ul>

<h2 id="Examples" name="Examples">例</h2>

<pre class="brush:js;">
Object.is("foo", "foo");     // true
Object.is(window, window);   // true

Object.is("foo", "bar");     // false
Object.is([], []);           // false

// 同値演算子と戻り値が異なるケース
Object.is(0, -0);            // false
Object.is(NaN, 0/0);         // true</pre>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザ実装状況</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>機能</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>基本サポート</td>
   <td>?</td>
   <td>{{CompatGeckoDesktop("22")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>機能</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>基本サポート</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoDesktop("22")}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>
このリビジョンへ戻す