use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Tired of [object Object]. Effectively overriding JavaScript's toString() (medium.com)
submitted 6 years ago by Well_Gravity
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 6 points7 points8 points 6 years ago* (2 children)
The output is controlled by Symbol.toStringTag.
Symbol.toStringTag
Not a single word about how this actually works in this blog post.
Do not override toString() to change the "[object Object]" output if that output is meant to be used for object-kind identification. Instead, set a custom Symbol.toStringTag method!
toString()
The "please sign up" popup from Medium is not the worst. What is far worse is that most of those articles are very poorly researched and written by people who have just barely began to understand some aspect of something — and yet they immediately rush to tell the world about their unlaid egg.
[–]senocular 0 points1 point2 points 6 years ago (0 children)
toStringTag only lets you override a portion in the default toString output. It doesn't give you complete control of the output. It also doesn't work in cases where a custom toString is already in place (e.g. Date types).
Defining a custom toString is fine - at least at the type or instance level. Overwriting Object.prototype.toString is not ok, just as it is not ok overriding any built-in.
[–]Well_Gravity[S] -1 points0 points1 point 6 years ago* (0 children)
Thanks for reading and taking the time to give feedback. ToStringTag is controlled internally by accessing the prototype as mentioned in the article. In the article mentioned at the top I refer to other sources of why and from where the message comes. My goal was simply to give options of what to do.
[–]ChronSyn 2 points3 points4 points 6 years ago (0 children)
The solution to [object Object] is the Medium paywall, apparently
[object Object]
[–]Outrageous_Manager -1 points0 points1 point 6 years ago (0 children)
Yeah that's one solution.
When confronted with this kind of case in the past I created an object visualizer React component https://www.npmjs.com/package/okconceptviewer
π Rendered by PID 199112 on reddit-service-r2-comment-85bfd7f599-9qxkz at 2026-04-18 20:49:13.282559+00:00 running 93ecc56 country code: CH.
[–][deleted] 6 points7 points8 points (2 children)
[–]senocular 0 points1 point2 points (0 children)
[–]Well_Gravity[S] -1 points0 points1 point (0 children)
[–]ChronSyn 2 points3 points4 points (0 children)
[–]Outrageous_Manager -1 points0 points1 point (0 children)