What does [object Object] mean?

As others have noted, this is the default serialisation of an object. But why is it [object Object] and not just [object]?

That is because there are different types of objects in Javascript!

  • Function objects:
    stringify(function (){}) -> [object Function]
  • Array objects:
    stringify([]) -> [object Array]
  • RegExp objects
    stringify(/x/) -> [object RegExp]
  • Date objects
    stringify(new Date) -> [object Date]
  • several more
  • and Object objects!
    stringify({}) -> [object Object]

That’s because the constructor function is called Object (with a capital “O”), and the term “object” (with small “o”) refers to the structural nature of the thingy.

Usually, when you’re talking about “objects” in Javascript, you actually meanObject objects“, and not the other types.

where stringify should look like this:

function stringify (x) {
    console.log(Object.prototype.toString.call(x));
}

Leave a Comment