返回JS对象的类型
function objectType(obj)
{
var constructor = (String)(obj.constructor);
var tokens = constructor.split(" ");
for(var i=0; i<tokens.length; i++)
{
if(tokens[i].indexOf("function") != -1)
{
var end = tokens[i+1].indexOf("(");
if(end == -1)
return(tokens[i+1]);
else
return(tokens[i+1].substring(0, end));
}
}
}// END objectType
alert(objectType( 'I am a string')); //string
alert(objectType(true)); //boolean
alert(objectType(100)); //number