"Robert Mark Bram" <ro*********@yourshoesinfotech.monash.edu.au> writes:
How can you tell the type of an object?
I am not talking about using "typeof" ..
Yes, that would just give "object".
I am talking about being able to determine if an object is a Date or String
All built in constructors (String, Boolean, Number, Array, Date, RegExp, etc.)
have a prototype with a property called "constructor" that points to itself.
That is
var x = new String("foo");
alert(x.constructor == String);
alerts true. You can use this to recognize the objects constructed by these
constructors *unless* someone fiddled with the constructor property. There
is nothing that prevents you from doing:
String.prototype.constructor = Array
(except common sense). So, the method is not fool proof, if the fools are
too inventive.
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'