var a="zhangqian"; var b=true; var c=10; var d; var e = null; var f=new Object(); alert(typeof a); //string alert(typeof b); //boolean alert(typeof c); //number alert(typeof d); //undefined alert(typeof e); //object alert(typeof f); //object
2. instanceof mainly detects the reference type and returns a boolean value. The instanceof operator can be used to determine whether the prototype property of a constructor exists on the prototype chain of another object to be tested.
var array=new Array(); var object=new Object(); var regexp=new RegExp(); function func(){}; var func1 = new func (); alert(array instanceof Array); //true alert(object instanceof Object); //true alert(regexp instanceof RegExp); //true alert(func1 instanceof func); //true
More related explanation links:
http://blog.csdn.net/myhahaxiao/article/details/6740542
http://blog.csdn.net/mevicky/article/details/50353881