Revision: 2228
Updated Code
at January 21, 2007 21:36 by rolandog
Updated Code
var is={
Null:function(a){
return a===null;
},
Undefined:function(a){
return a===undefined;
},
nt:function(a){
return(a===null||a===undefined);
},
Function:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/Function/)!==null:false;
},
String:function(a){
return(typeof(a)==='string')?true:(typeof(a)==='object')?a.constructor.toString().match(/string/i)!==null:false;
},
Array:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/array/i)!==null||a.length!==undefined:false;
},
Boolean:function(a){
return(typeof(a)==='boolean')?true:(typeof(a)==='object')?a.constructor.toString().match(/boolean/i)!==null:false;
},
Date:function(a){
return(typeof(a)==='date')?true:(typeof(a)==='object')?a.constructor.toString().match(/date/i)!==null:false;
},
HTML:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/html/i)!==null:false;
},
Number:function(a){
return(typeof(a)==='number')?true:(typeof(a)==='object')?a.constructor.toString().match(/Number/)!==null:false;
},
Object:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/object/i)!==null:false;
},
RegExp:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/regexp/i)!==null:false;
}
};
var type={
of:function(a){
for(var i in is){
if(is[i](a)){
return i.toLowerCase();
}
}
}
};
Revision: 2227
Updated Code
at January 17, 2007 21:13 by rolandog
Updated Code
var is={
Null:function(a){
return a===null;
},
Undefined:function(a){
return a===undefined;
},
Function:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/Function/)!==null:false;
},
Array:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/array/i)!==null:false;
},
Boolean:function(a){
return(typeof(a)==='boolean')?true:(typeof(a)==='object')?a.constructor.toString().match(/boolean/i)!==null:false;
},
Date:function(a){
return(typeof(a)==='date')?true:(typeof(a)==='object')?a.constructor.toString().match(/date/i)!==null:false;
},
HTML:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/html/i)!==null:false;
},
Number:function(a){
return(typeof(a)==='number')?true:(typeof(a)==='object')?a.constructor.toString().match(/Number/)!==null:false;
},
Object:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/object/i)!==null:false;
},
RegExp:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/regexp/i)!==null:false;
},
String:function(a){
return(typeof(a)==='string')?true:(typeof(a)==='object')?a.constructor.toString().match(/string/i)!==null:false;
}
};
var type={
of:function(a){
for(var i in is){
if(is[i](a)){
return i.toLowerCase();
}
}
}
};
Revision: 2226
Updated Code
at January 17, 2007 21:12 by rolandog
Updated Code
var is={
Null:function(a){
return a===null;
},
Undefined:function(a){
return a===undefined;
},
Function:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/Function/)!==null:false;
},
Array:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/array/i)!==null:false;
},
Boolean:function(a){
return(typeof(a)==='boolean')?true:(typeof(a)==='object')?a.constructor.toString().match(/boolean/i)!==null:false;
},
Date:function(a){
return(typeof(a)==='date')?true:(typeof(a)==='object')?a.constructor.toString().match(/date/i)!==null:false;
},
HTML:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/html/i)!==null:false;
},
Number:function(a){
return(typeof(a)==='number')?true:(typeof(a)==='object')?a.constructor.toString().match(/Number/)!==null:false;
},
Object:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/object/i)!==null:false;
},
RegExp:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/regexp/i)!==null:false;
},
String:function(a){
return(typeof(a)==='string')?true:(typeof(a)==='object')?a.constructor.toString().match(/string/i)!==null:false;
}
};
var type={
of:function(a){
for(var i in is){
if(is[i](a)){
return i.toLowerCase();
}
}
}
};
Revision: 2225
Updated Code
at January 17, 2007 21:10 by rolandog
Updated Code
// Adapted from http://www.planetpdf.com/developer/article.asp?ContentID=testing_for_object_types_in_ja
var is={
Null:function(a){
return a===null;
},
Undefined:function(a){
return a===undefined;
},
Function:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/Function/)!==null:false;
},
Array:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/array/i)!==null:false;
},
Boolean:function(a){
return(typeof(a)==='boolean')?true:(typeof(a)==='object')?a.constructor.toString().match(/boolean/i)!==null:false;
},
Date:function(a){
return(typeof(a)==='date')?true:(typeof(a)==='object')?a.constructor.toString().match(/date/i)!==null:false;
},
HTML:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/html/i)!==null:false;
},
Number:function(a){
return(typeof(a)==='number')?true:(typeof(a)==='object')?a.constructor.toString().match(/Number/)!==null:false;
},
Object:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/object/i)!==null:false;
},
RegExp:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/regexp/i)!==null:false;
},
String:function(a){
return(typeof(a)==='string')?true:(typeof(a)==='object')?a.constructor.toString().match(/string/i)!==null:false;
}
};
var type={
of:function(a){
for(var i in is){
if(is[i](a)){
return i.toLowerCase();
}
}
}
};
Revision: 2224
Updated Code
at January 17, 2007 21:08 by rolandog
Updated Code
var is={
Null:function(a){
return a===null;
},
Undefined:function(a){
return a===undefined;
},
Function:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/Function/)!==null:false;
},
Array:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/array/i)!==null:false;
},
Boolean:function(a){
return(typeof(a)==='boolean')?true:(typeof(a)==='object')?a.constructor.toString().match(/boolean/i)!==null:false;
},
Date:function(a){
return(typeof(a)==='date')?true:(typeof(a)==='object')?a.constructor.toString().match(/date/i)!==null:false;
},
HTML:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/html/i)!==null:false;
},
Number:function(a){
return(typeof(a)==='number')?true:(typeof(a)==='object')?a.constructor.toString().match(/Number/)!==null:false;
},
Object:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/object/i)!==null:false;
},
RegExp:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/regexp/i)!==null:false;
},
String:function(a){
return(typeof(a)==='string')?true:(typeof(a)==='object')?a.constructor.toString().match(/string/i)!==null:false;
}
};
var type={
of:function(a){
for(var i in is){
if(is[i](a)){
return i.toLowerCase();
}
}
}
};
Revision: 2223
Updated Code
at January 17, 2007 21:07 by rolandog
Updated Code
var is={
Null:function(a){
return a===null;
},
Undefined:function(a){
return a===undefined;
},
Function:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/Function/)!==null:false;
},
Array:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/array/i)!==null:false;
},
Boolean:function(a){
return(typeof(a)==='boolean')?true:(typeof(a)==='object')?a.constructor.toString().match(/boolean/i)!==null:false;
},
Date:function(a){
return(typeof(a)==='date')?true:(typeof(a)==='object')?a.constructor.toString().match(/date/i)!==null:false;
},
HTML:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/html/i)!==null:false;
},
Number:function(a){
return(typeof(a)==='number')?true:(typeof(a)==='object')?a.constructor.toString().match(/Number/)!==null:false;
},
Object:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/object/i)!==null:false;
},
RegExp:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/regexp/i)!==null:false;
},
String:function(a){
return(typeof(a)==='string')?true:(typeof(a)==='object')?a.constructor.toString().match(/string/i)!==null:false;
}
};
var type={
of:function(a){
for(var i in is){
if(is[i](a)){
return i.toLowerCase();
}
}
}
};
Revision: 2222
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 17, 2007 21:00 by rolandog
Initial Code
var is={
Null:function(a){
return a===null;
},
Undefined:function(a){
return a===undefined;
},
Function:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/Function/)!==null:false;
},
Array:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/array/i)!==null:false;
},
Boolean:function(a){
return(typeof(a)==='boolean')?true:(typeof(a)==='object')?a.constructor.toString().match(/boolean/i)!==null:false;
},
Date:function(a){
return(typeof(a)==='date')?true:(typeof(a)==='object')?a.constructor.toString().match(/date/i)!==null:false;
},
HTML:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/html/i)!==null:false;
},
Number:function(a){
return(typeof(a)==='number')?true:(typeof(a)==='object')?a.constructor.toString().match(/Number/)!==null:false;
},
Object:function(a){
return(typeof(a)==='object')?a.constructor.toString().match(/object/i)!==null:false;
},
RegExp:function(a){
return(typeof(a)==='function')?a.constructor.toString().match(/regexp/i)!==null:false;
},
String:function(a){
return(typeof(a)==='string')?true:(typeof(a)==='object')?a.constructor.toString().match(/string/i)!==null:false;
}
};
var type={
of:function(a){
for(var i in is){
if(is[i](a)){
return i.toLowerCase();
}
}
}
};
Initial URL
http://rolandog.com/archives/2007/01/18/typeof-a-more-specific-typeof/
Initial Description
Helps identify correctly the type of whatever you put as an argument. This was adapted from http://www.planetpdf.com/developer/article.asp?ContentID=testing_for_object_types_in_ja
Initial Title
type.of() - a more specific typeof()
Initial Tags
object, array
Initial Language
JavaScript