This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

JSON.stringify() will remove any functions from an object.

// create JavaScript object with an "age" function
const obj = {name: "John", age: function () {return 30;}, city: "New York"};

// convert JS object to JSON string, deletes the age function before creating the string
const myJSON = JSON.stringify(obj);
document.getElementById("demo").innerHTML = myJSON;

JavaScript Functions are not allowed in JSON.stringify() strings. They are removed from the JavaScript object by the JSON.stringify() function.