DEV Community

Cover image for 5 Secret features of JSON in JavaScript you didn't know about 🤯

5 Secret features of JSON in JavaScript you didn't know about 🤯

Siddharth on March 01, 2022

I'm pretty sure you have used the global JSON object for a variety of things, like in fetch requests and to avoid the dreaded [object Object]. I al...
Collapse
 
toxictoast profile image
ToxicToast

Please edit the Title.
This has nothing todo with JSON directly it's more features of Javascript you're showing...

Collapse
 
siddharthshyniben profile image
Siddharth

I meant the JSON object in JavaScript, yes. I'll edit it. Thanks!

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

Well JSON states for JavaScript Object Notation so I'm giving a point to the OP here 😂

Collapse
 
siddharthshyniben profile image
Siddharth

I never really thought about that 😂

Collapse
 
toxictoast profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct
ToxicToast

Oh a "Knows it all" if you want to smartass, then you probably know that JSON is still not the same as Javascript.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇

Of course not, I just defined what JSON states for. Please sir, continue scrolling, nothing to see here

Collapse
 
biomathcode profile image
Pratik sharma

+1

Collapse
 
insign profile image
Hélio oliveira

Agreed. Looks like clickbait.

Collapse
 
siddharthshyniben profile image
Siddharth

All clickbait isn't bad

Collapse
 
lioness100 profile image
Lioness100

I ran a quick benchmark and didn't realize how much passing an array of keys helps performance! I'll look out for that in the future, thanks 💪

Collapse
 
cerchie profile image
Lucia Cerchie

🤯 Thanks for writing this, I learned a lot! What would a reviver for an array like the cakes array look like? Would you filter the array and populate the rest of the details if the name matched?

Collapse
 
siddharthshyniben profile image
Siddharth

It would probably be impossible to write a reviver for the current reducer I wrote, since all data is deleted. If we did have a reference to the original array, yes we could find the matching cake and then populate the rest of the data.

Collapse
 
cerchie profile image
Lucia Cerchie

Thanks for explaining that!

Collapse
 
sewellstephens profile image
sewellstephens

I would have never guessed the date function used revivers. I made a Zapier integration for my software product for the first time a few months ago and apparently, Zapier only likes Json Arrays for Triggers in the developer platform. They don't accept Objects.

It was also the first API I ever made ✨

Collapse
 
codesnail21 profile image
Vatsal

Awesome 😎

Collapse
 
siddharthshyniben profile image
Siddharth

😎

Collapse
 
lico profile image
SeongKuk Han • Edited

Awesome! Thanks for sharing

Collapse
 
siddharthshyniben profile image
Siddharth

Thanks!

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

👏 bravo I knew 1 and a half of these, learn something new about old dogs every day... Is that the expression

Collapse
 
sunflowertoadtheorbiter profile image
SunflowerToadTheOrbiter

Really cool, thanks for sharing!

Collapse
 
siddharthshyniben profile image
Siddharth

Thanks for reading, too!

Collapse
 
elijahtrillionz profile image
Elijah Trillionz

Great writeup.
Thanks for sharing

Collapse
 
5h0bh4nk profile image
Shubh4nk

Awesome

Collapse
 
starboysharma profile image
Pankaj Sharma

Really I don't know about this stuff. Thank you for sharing

Collapse
 
siddharthshyniben profile image
Siddharth

Thanks! :D