Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) Programming AJAX Parsing JSON Data

console.log output array()

I tried the video and the console.log the employee but it says it is an array. But in the video, it says its objects

var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
  if(xhr.readyState === 4){
    var employee = JSON.parse(xhr.responseText);
    console.log(employee);

  }
}
xhr.open('GET','data/employees.json');
xhr.send();

an array is also a type of object in JS read more

1 Answer

Jess Taylor
Jess Taylor
5,160 Points

You will get objects back, but It should be an ARRAY of objects :

If you look at your console window you should be able to see a set of square brackets on the outside, showing an array, and then all of the objects inside that array encased in these brackets { } to show that they are objects.

[{Object}, {Object}, {Object}....etc]