JavaScript/Object.prototype.toString.call:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第13行: 第13行:
Object.prototype.toString.call(new Date());
Object.prototype.toString.call(new Date());
Object.prototype.toString.call(/[1-9]at/gi);
Object.prototype.toString.call(/[1-9]at/gi);
Object.prototype.toString.call(JSON);</syntaxhighlight>|{{consoleout|<pre>
Object.prototype.toString.call(JSON);
Object.prototype.toString.call(1n);
Object.prototype.toString.call(Symbol());</syntaxhighlight>|{{consoleout|<pre>
"[object Array]"
"[object Array]"
"[object Object]"
"[object Object]"
第26行: 第28行:
"[object RegExp]"
"[object RegExp]"
"[object JSON]"
"[object JSON]"
"[object BigInt]"
"[object Symbol]"
</pre>}}}}
== 原生函数 ==
{{leftrightflex|<syntaxhighlight lang="javascript">
Object.prototype.toString.call(new String());
Object.prototype.toString.call(new Number());
Object.prototype.toString.call(new Boolean());
Object.prototype.toString.call(new Array());
Object.prototype.toString.call(new Object());
Object.prototype.toString.call(new Function());
Object.prototype.toString.call(new RegExp());
Object.prototype.toString.call(new Date());
Object.prototype.toString.call(new Error());
</syntaxhighlight>|{{consoleout|<pre>"[object String]"
"[object Number]"
"[object Boolean]"
"[object Array]"
"[object Object]"
"[object Function]"
"[object RegExp]"
"[object Date]"
"[object Error]"
</pre>}}}}
</pre>}}}}



2020年6月26日 (五) 06:21的版本

引言

示例

模板:Leftrightflex

原生函数

模板:Leftrightflex

判断

判断原生JSON对象

var isNativeJSON = window.JSON && Object.prototype.toString.call(JSON);