aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/operators/strict_inequality
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/operators/strict_inequality
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/operators/strict_inequality')
-rw-r--r--files/zh-cn/web/javascript/reference/operators/strict_inequality/index.html95
1 files changed, 95 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/operators/strict_inequality/index.html b/files/zh-cn/web/javascript/reference/operators/strict_inequality/index.html
new file mode 100644
index 0000000000..e71f28c100
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/operators/strict_inequality/index.html
@@ -0,0 +1,95 @@
+---
+title: 严格不相等 (!==)
+slug: Web/JavaScript/Reference/Operators/Strict_inequality
+translation_of: Web/JavaScript/Reference/Operators/Strict_inequality
+---
+<div>{{jsSidebar("Operators")}}</div>
+
+<p><span>严格不等式操作符(!==)检查它的两个对象是否不相等,返回一个布尔结果。与不等式运算符不同,严格不等式运算符总是认为不同类型的对象是不同的。</span></p>
+
+<div>{{EmbedInteractiveExample("pages/js/expressions-strict-equality.html")}}</div>
+
+<div class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox notranslate">x !== y</pre>
+
+<h2 id="描述">描述</h2>
+
+<p><span>严格不等式运算符检查其对象是否不相等。它是严格相等运算符的否定,因此下面两行总是会给出相同的结果:</span></p>
+
+<pre class="brush: js notranslate">x !== y
+
+!(x === y)</pre>
+
+<p><span>有关比较算法的详细信息,请参阅严格相等运算符的页面。</span></p>
+
+<p><span>与严格相等运算符一样,严格不等运算符始终认为不同类型的对象是不同的</span>:</p>
+
+<pre class="brush: js notranslate">3 !== "3"; // true</pre>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="比较相同类型的对象">比较相同类型的对象</h3>
+
+<pre class="brush: js notranslate">console.log("hello" !== "hello"); // false
+console.log("hello" !== "hola"); // true
+
+console.log(3 !== 3); // false
+console.log(3 !== 4); // true
+
+console.log(true !== true); // false
+console.log(true !== false); // true
+
+console.log(null !== null); // false</pre>
+
+<h3 id="比较不同类型的对象">比较不同类型的对象</h3>
+
+<pre class="brush: js notranslate">console.log("3" !== 3); // true
+
+console.log(true !== 1); // true
+
+console.log(null !== undefined); // true</pre>
+
+<h3 id="比较Object对象">比较Object对象</h3>
+
+<pre class="brush: js notranslate">const object1 = {
+ name: "hello"
+}
+
+const object2 = {
+ name: "hello"
+}
+
+console.log(object1 !== object2); // true
+console.log(object1 !== object1); // false</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-equality-operators', 'Equality operators')}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容">浏览器兼容</h2>
+
+
+
+<p>{{Compat("javascript.operators.strict_inequality")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Equality">Equality operator</a></li>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Inequality">Inequality operator</a></li>
+ <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality">Strict equality operator</a></li>
+</ul>