The constructor Property

[size=medium]Since constructor functions define new categories or classes of objects, the constructor property can help
determine the type of an object. For example, you might use code like the following to determine the type
of an unknown value:
if ((typeof o == "object") && (o.constructor == Date))
     // Then do something with the Date object...

The instanceof operator checks the value of the constructor property, so the code above could also be
written:
if ((typeof o == "object") && (o instanceof Date))
     // Then do something with the Date object...

[/size]

你可能感兴趣的:(JavaScript)