How to Convert Javascript Array to JSON Object Using JSON.stringify() Method Full Project For Beginners


Welcome folks today in this blog post we will be converting javascript array to json object using json.stringify() method in javascript. All the full source code of the application is shown below.




Get Started




In order to get started you need to make an index.js file and copy paste the following code






let arr = [ "John", "Mike", "Sam", "Lisa", "Kane", "Don", "Luis", "Mimi" ];

let str = JSON.stringify({...arr});

console.log(str); // "{"0":"John","1":"Mike","2":"Sam","3":"Lisa","4":"Kane","5":"Don","6":"Luis","7":"Mimi"}"

console.log(typeof(str)); // string


Leave a Reply