typeof应该注意的地方(网龙公司校招笔试题)

 1 <script language="javascript" type="text/javascript"> 
 2   alert(new String('a')==='a');       //true
 3   alert(Function instanceof Object);//true
 4   alert(NaN!==NaN);                     //true
 5   alert(typeof []==='Object');        //false
 6 </script>
 7 
 8 <script language="javascript" type="text/javascript"> 
 9   alert(new String('a')==='a');          //true
10   alert(Function instanceof Function);//true
11   alert(NaN!==NaN);                        //true
12   alert(typeof []==='object');           //true
13 
14     alert(typeof(typeof [])==='string');//true
15 </script>

注意:Function instanceof Object/Function instanceof Function都是true;typeof返回的值是String类型并且全部是小写的,所以typeof []==='Object'返回的是false

 

posted @ 2014-10-25 16:46  暗语321  阅读(401)  评论(0编辑  收藏  举报