formatObject()function

formatObject(obj: ImmutableObject): string
ParamType
objImmutableObject
Object to format. required
Return
string
Best-available string representation of obj, or "Object" as a fallback.

Format an unknown object as a string.

  • Use the custom .toString() function if it exists (don't use built in Object.prototype.toString because it's useless.
  • Use .title or .name or .id if they exist and are strings.
  • Use Object otherwise.

Examples

formatObject({ name: "Dave" }) // "Dave"