Posted by skoch on 23. April 2009
this.Typeof = function (object) {
if (object == null)
return 'null';
if (typeof object == 'undefined')
return 'undefined';
if (object.nodeName && object.nodeType == 1)
return 'element';
if (object.nodeName && object.nodeType == 3 && (!/\S/).test(object.nodeValue))
return 'textnode';
if (object instanceof Function)
return 'function';
if (object instanceof Array)
return 'array';
if (typeof object == 'object')
return 'object';
if (typeof object == 'number' && isFinite(obj))
return 'number';
if (typeof object == 'string')
return 'string';
if (typeof object == 'boolean')
return 'boolean';
};
Filed under: JavaScript
Leave a Reply
You must be logged in to post a comment.