function toType(obj) {
  var systype = ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1];
  if (systype === "Object") {
    /**
     * See if this is a custom user type, a la:
     *   function Foo() {}
     *   foo = new Foo();
     *   toType(foo); // returns "Foo"
     *   toType(Foo); // returns "Function"
     */
    var usertype = obj.constructor.toString().match(/function (.*?)\(/)[1];
    return usertype;
  } else {
    return systype;
  }
}