From 669817dd790452f7622567e70fec7a4175f4ce2e Mon Sep 17 00:00:00 2001 From: ChowQ <56550691+CFCode-git@users.noreply.github.com> Date: Mon, 26 Apr 2021 16:45:26 +0800 Subject: Update index.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按照 ECMAScript 2020 规范,数据类型只有八种。 链接 >> https://tc39.es/ecma262/#sec-ecmascript-data-types-and-values --- files/zh-cn/web/javascript/data_structures/index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'files/zh-cn') diff --git a/files/zh-cn/web/javascript/data_structures/index.html b/files/zh-cn/web/javascript/data_structures/index.html index 5b3e069800..479e7222f9 100644 --- a/files/zh-cn/web/javascript/data_structures/index.html +++ b/files/zh-cn/web/javascript/data_structures/index.html @@ -23,7 +23,7 @@ foo = true; // foo is a Boolean now
最新的 ECMAScript 标准定义了 9 种数据类型:
+最新的 ECMAScript 标准定义了 8 种数据类型:
typeof instance === "object"
。typeof instance === "object"
。任何 {{Glossary("constructed")}} 对象实例的特殊非数据结构类型,也用做数据结构:new {{Glossary("Object")}},new {{Glossary("Array")}},new {{Glossary("Map")}},new {{Glossary("Set")}},new {{Glossary("WeakMap")}},new {{Glossary("WeakSet")}},new {{Glossary("Date")}},和几乎所有通过 {{Glossary("new keyword")}} 创建的东西。typeof instance === "function"
。这个结果是为 Function 的一个特殊缩写,尽管每个 Function 构造器都由 Object 构造器派生。记住 typeof
操作符的唯一目的就是检查数据类型,如果我们希望检查任何从 Object 派生出来的结构类型,使用 typeof
是不起作用的,因为总是会得到 "object"
。检查 Object 种类的合适方式是使用 {{Glossary("instanceof")}} 关键字。但即使这样也存在误差。