This indeed woks :  function isObj(o){ return
Object.prototype.toString.call(o) === '[object Object]' }

But I do not like it ;o) It does not seem very exact somehow ... I
mean using a string literal, and all that...
I would suggest this very simple and robust little set of functions :

// and now much simpler implementation
function isWhat(o){ return Object.prototype.toString.call(o).match(/\w
+/g)[1]; }

function isObject(x) { return isWhat(x) === isWhat({}); }
function isArray(x)  { return isWhat(x) === isWhat([]); }
function isFunction(x) { return isWhat(x) === isWhat(Function()); }
function isString(x) { return isWhat(x) === isWhat(""); }
function isNumber(x) { return isWhat(x) === isWhat(1); }

No obfuscations here, and no "awesome" code. This seems very simple
and robust solution to me.

--DBJ


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to