code: function type(input) {
  
    //If the input value is null, undefined or NaN the toStringTypes object shouldn't be used
    if (input === null || input === undefined || (input !== input && String(input) === "NaN")) {
      return String(input);
    }
  
    // use the typeMap to detect the type and fallback to object if the type wasn't found
    return typeMap[Object.prototype.toString.call(input)] || "object";
  }
docs: detect type using typeMap