码迷,mamicode.com
首页 > 其他好文 > 详细

Object.prototype.toString.call()进行类型判断

时间:2015-11-27 16:56:37      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

 1 <!doctype html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6 </head>
 7 <body>
 8 <script>
 9     var a1 = {
10         c:1,
11         d:2
12     }
13     var a2 = [1,2,3];
14     var a3 = 2;
15     var a4 = "wwww";
16     var b1 = Object.prototype.toString.call(a1);
17     var b2 = Object.prototype.toString.call(a2);
18     var b3 = Object.prototype.toString.call(a3);
19     var b4 = Object.prototype.toString.call(a4);
20     var b5 = Object.prototype.toString.call(null);
21     var b6 = Object.prototype.toString.call(NaN);
22     console.log(b1);
23     console.log(b2);
24     console.log(b3);
25     console.log(b4);
26     console.log(b5);
27     console.log(b6);
28     console.log(NaN)
29 </script>
30 </body>
31 </html>

 

Object.prototype.toString.call()进行类型判断

标签:

原文地址:http://www.cnblogs.com/suoking/p/5000856.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!