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

时间:2021-09-12 17:10:48
 <script language="javascript" type="text/javascript">
  alert(new String('a')==='a'); //true
  alert(Function instanceof Object);//true
  alert(NaN!==NaN); //true
  alert(typeof []==='Object'); //false
</script> <script language="javascript" type="text/javascript">
  alert(new String('a')==='a'); //true
  alert(Function instanceof Function);//true
  alert(NaN!==NaN); //true
  alert(typeof []==='object'); //true   alert(typeof(typeof [])==='string');//true
</script>

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