What does [object Object] mean? What does [object Object] mean? jquery jquery

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 mean "Object objects", and not the other types.

where stringify should look like this:

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


The default conversion from an object to string is "[object Object]".

As you are dealing with jQuery objects, you might want to do

alert(whichIsVisible()[0].id);

to print the element's ID.

As mentioned in the comments, you should use the tools included in browsers like Firefox or Chrome to introspect objects by doing console.log(whichIsVisible()) instead of alert.

Sidenote: IDs should not start with digits.


[object Object] is the default toString representation of an object in javascript.

If you want to know the properties of your object, just foreach over it like this:

for(var property in obj) {    alert(property + "=" + obj[property]);}

In your particular case, you are getting a jQuery object. Try doing this instead:

$('#senddvd').click(function (){   alert('hello');   var a=whichIsVisible();   alert(whichIsVisible().attr("id"));});

This should alert the id of the visible element.