What is the purpose of JSON.stringify() in JavaScript?

What is the purpose of JSON.stringify() in JavaScript?

a) To convert a JavaScript object into a JSON string
b) To convert a JSON string into a JavaScript object
c) To sort the properties of a JavaScript object
d) To clone a JavaScript object

Answer:

a) To convert a JavaScript object into a JSON string

Explanation:

The JSON.stringify() method converts a JavaScript object or value into a JSON string. This is useful for storing or sending data in a text format, such as transmitting data between a server and web application.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top