Typed array returns object in console.log?

Tell us what’s happening:
Describe your issue in detail here.

Your code so far


var buffer = new ArrayBuffer(64);
var i32View = new Int32Array(buffer) ;
console.log(i32View)


Your buffer should be 64 bytes large.

Your i32View view of your buffer should be 64 bytes large.

Your i32View view of your buffer should be 16 elements long.


{ '0': 0,
  '1': 0,
  '2': 0,
  '3': 0,
  '4': 0,
  '5': 0,
  '6': 0,
  '7': 0,
  '8': 0,
  '9': 0,
  '10': 0,
  '11': 0,
  '12': 0,
  '13': 0,
  '14': 0,
  '15': 0 }

This passes, but I’m confused. The examples imply that an array should be returned, but I see an object in console.log? is that something that changed since this exercise was implemented?

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0

Challenge: Typed Arrays

Link to the challenge:

In JavaScript arrays are technically a type of object. (Try creating a simple array and then console logging the typeof that array.) While most consoles will print a standard array in the way we’re used to seeing, some will interpret typed arrays as an object with the indices as keys. It looks like that is the case with the console emulator built into the editor. If you open your browser’s console (F12) you’ll probably see something closer to what you expect.

2 Likes

OK that makes sense. I did try in the browser console. But I just now facepalmed :crazy_face: when i realized I was trying console.log(i32View) in the console…It does output in the console as an array. Thank you.

Cool beans. I’m glad I could help. Happy coding!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.