xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to create a JSON string array in JavaScript
JavaScript Online Editor
Run Code
More JavaScript Sample Codes
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>How to create a JSON string array in JavaScript</title> <!--Script is added to write JavaScript code inside it--> <script> //create a JSON string array const jsonString = '[{"name":"John Smith", "age": 19}, {"name":"Martin Taylor", "age": 21}]'; //JSON array contains two JSON string objects: {"name":"John Smith", "age": 19} and {"name":"Martin Taylor", "age": 21} //Each object represents a person with a "name" and an "age" property. function myFunction() { //display JSON string document.getElementById("outPut").innerHTML = "<p>This is a JSON string array:</P>" + jsonString; }; </script> </head> <body> <h1>How to create a JSON string array in JavaScript</h1> <button onclick="myFunction()">Click here to see result</button> <p id="outPut"></p> </body> </html>