Posts

Showing posts from September, 2025

Difference between JSON.stringify() and JSON.parse()

  Difference between  JSON.stringify()  and  JSON.parse() Function What it does Input Output When to use JSON.stringify() Converts a  JavaScript object/array  into a  JSON string Object / Array String When sending data to a server or storing it (like in localStorage) JSON.parse() Converts a  JSON string  back into a  JavaScript object/array String Object / Array When receiving JSON data from a server or reading stored data 📘 Example <!DOCTYPE html> <html> <head>     <title>JSON Example</title> </head> <body>     <script>         // Example Student Object         var student = {             name: "Sanjay",             age: 23,             className: "10A",             location: "Delhi"         ...