Syntax: JSON.stringify(value[, replacer[, space]])
where, replacer
is used to apply modifications to the value while stringifying
and space
specifies the indentation of the value.
const obj = {
name: "ABC",
age: 200,
skills: ["C", "JavaScript", "Python"],
};
console.log(JSON.stringify(obj, null, 2));
Prints result as:
{
"name": "test",
"age": 26,
"skills": [
"c",
"javascript",
"php"
]
}
Thanks for reading 💙
Follow @codedrops.tech for daily posts.
Instagram ● Twitter ● Facebook
Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript
codedrops.tech
Top comments (3)
This is actually pretty cool for when we want to check out responses from an API on a new tab
Offcourse 😀
I just did a video about it. Check it out if you want youtu.be/COwckZNzlNg