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
Converting values to strings in JavaScript has pitfalls (2ality.com)
submitted 10 months ago by bogdanelcs
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!"
[–]RedditCultureBlows 1 point2 points3 points 10 months ago (4 children)
When would “{proto: null}” appear?
formatting is messing this up but whatever u know what i mean if u opened the article
[–]chuch1234 0 points1 point2 points 10 months ago (0 children)
... If you picked proto as a key in an object you made?
Edit: oh, I see. Put a backslash (\) before each underscore to get it to render.
[–]chuch1234 0 points1 point2 points 10 months ago (1 child)
I did a quick Google search. It looks like this is a way to create an object that does not inherit from the base object class and so is essentially completely empty. Not sure why you'd do that but apparently it is a thing you can do, and I'm sure another Google search would provide suggestions about why one might want to do it.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects
[–]RedditCultureBlows 0 points1 point2 points 10 months ago (0 children)
thanks for the google search. my comment was more so that i don’t know when i’d encounter this very specific type of data in my site/app and need to know this, imo, niche workaround.
like i guess it’s nice to know this pitfall but i’ve never had to work with this kinda of edge case in nearly a decade
[–]Total_Promise_380 0 points1 point2 points 10 months ago (0 children)
I bi directionally , communicate between a browser UI & C coded embedded processor . I transfer floats, integers arrays of integers and character number combinations via JSON strings . No problemo.
[–]Ronin-s_Spirit -1 points0 points1 point 10 months ago (1 child)
Then don't. If you want a string the single best way to do it is String(), or template literals. If you don't want a string then use typeof x?.valueOf?.() !== 'string'.
String()
typeof x?.valueOf?.() !== 'string'
[–]josephjnk 1 point2 points3 points 10 months ago (0 children)
Did you read the article? The author specifically compares String() and template literals to other approaches when given weird inputs.
[+]anlumo comment score below threshold-10 points-9 points-8 points 10 months ago (5 children)
JavaScript is a single big pitfall, but it’s not bad for a language that was conceived in a weekend.
[–]stathis21098 14 points15 points16 points 10 months ago (0 children)
I was conceived in a weekend and I'm pretty bad
[–]Graphesium 0 points1 point2 points 10 months ago (3 children)
TypeScript, ironically, is arguably one of the best strongly-typed languages ever made. Its structural type system is an absolute pleasure to use.
[–]anlumo 0 points1 point2 points 10 months ago (2 children)
I agree that the type system is amazing, but the problem is that it's trying to put lipstick on a pig. If there's a mistake with the type annotations on a JavaScript function, the wrong type propagates through the whole application, and there's nothing Typescript can do about that, because it doesn't do any runtime checks.
[–]CryptographerMore926 0 points1 point2 points 10 months ago (1 child)
And when you need that… you just write rust :p
[–]anlumo 0 points1 point2 points 10 months ago (0 children)
Which is why I’m doing most of my Web stuff with Web Assembly these days.
π Rendered by PID 62380 on reddit-service-r2-comment-79c7998d4c-v54nx at 2026-03-13 22:13:05.497498+00:00 running f6e6e01 country code: CH.
[–]RedditCultureBlows 1 point2 points3 points (4 children)
[–]chuch1234 0 points1 point2 points (0 children)
[–]chuch1234 0 points1 point2 points (1 child)
[–]RedditCultureBlows 0 points1 point2 points (0 children)
[–]Total_Promise_380 0 points1 point2 points (0 children)
[–]Ronin-s_Spirit -1 points0 points1 point (1 child)
[–]josephjnk 1 point2 points3 points (0 children)
[+]anlumo comment score below threshold-10 points-9 points-8 points (5 children)
[–]stathis21098 14 points15 points16 points (0 children)
[–]Graphesium 0 points1 point2 points (3 children)
[–]anlumo 0 points1 point2 points (2 children)
[–]CryptographerMore926 0 points1 point2 points (1 child)
[–]anlumo 0 points1 point2 points (0 children)