formatObject()function
formatObject(obj: ImmutableObject): string
| Param | Type | |
|---|---|---|
obj | ImmutableObject | 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 inObject.prototype.toStringbecause it's useless. - Use
.titleor.nameor.idif they exist and are strings. - Use
Objectotherwise.
Examples
formatObject({ name: "Dave" }) // "Dave"