查看“︁JavaScript/typeof”︁的源代码
来自康健生活
←
JavaScript/typeof
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 引言 == {| class="wikitable" |- | undefined || Undefined 类型 |- | boolean || Boolean 类型 |- | number || Number 类型 |- | string || String 类型 |- | object || 引用类型或 Null 类型 |} == 实例 == {{Leftrightflex|<syntaxhighlight lang="javascript"> typeof Symbol() typeof function(){} typeof class C{} typeof [] typeof {} typeof true typeof "str" typeof 1; typeof undefined; typeof null; typeof new String(); typeof new Number(); typeof new Array(); typeof new Object(); typeof new Function(); typeof new RegExp(); typeof new Date(); typeof new Error(); typeof 1n; typeof BigInt("1");</syntaxhighlight> |{{Consoleout|<pre>"symbol" "function" "function" "object" "object" "boolean" "string" "number" "undefined" "object" "object" "object" "object" "object" "function" "object" "object" "object" "bigint" "bigint" </pre>}} }} == null == 类型检测 {{leftrightflex|<syntaxhighlight lang="javascript">!null&&typeof null === "object"</syntaxhighlight>|{{consoleout|<pre>true </pre>}}}} == 原理 == 机器码低三位: {| class="wikitable" |- | 000 || 对象 || 示例 |- | 010 || 浮点数 || 示例 |- | 100 || 字符串 || 示例 |- | 110 || 布尔值 || 示例 |- | 1 || 整数 || 示例 |} == undefined 和 null == {{Leftrightflex|<syntaxhighlight lang="javascript"> undefined == null; undefined === null; Number(undefined); Number(null);</syntaxhighlight> |{{Consoleout|<pre>true false NaN 0</pre>}} }}
此页面嵌入的页面:
模板:Consoleout
(
查看源代码
)
模板:Double-columns
(
查看源代码
)
模板:Double-columns/style.css
(
查看源代码
)
返回
JavaScript/typeof
。
导航菜单
康健生活
搜索
user-page
通知
user-interface-preferences
个人工具
登录
五一
多读书,多运动,多到远处走走,再看看不一样的世界。