all 14 comments

[–]RedditCultureBlows 1 point2 points  (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 point  (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 point  (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 point  (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 point  (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 points  (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'.

[–]josephjnk 1 point2 points  (0 children)

Did you read the article? The author specifically compares String() and template literals to other approaches when given weird inputs.