When we use JSON.parse() on a JSON
derived from an array
, the method will return a JavaScript array, instead of an object
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    var myArr = JSON.parse(this.responseText);
    document.getElementById("demo").innerHTML = myArr[0];
  }
};
xmlhttp.open("GET", "json_demo_array.txt", true);
xmlhttp.send();
by Valeri Tandilashvili
4 years ago
JSON
JavaScript
JS JSON
1
Pro tip: use ```triple backticks around text``` to write in code fences