What Does [Object Object] Mean

What does [object Object] mean?

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.

What does [object Object] mean? (JavaScript)

It means you are alerting an instance of an object. When alerting the object, toString() is called on the object, and the default implementation returns [object Object].

var objA = {};
var objB = new Object;
var objC = {};

objC.toString = function () { return "objC" };

alert(objA); // [object Object]
alert(objB); // [object Object]
alert(objC); // objC

If you want to inspect the object, you should either console.log it, JSON.stringify() it, or enumerate over it's properties and inspect them individually using for in.

Why does this log [object Object], [object Object]?

This is because there is type coercion in your expression. Try to output this: console.log('Contacts: ${JSON.stringify(this.state.contacts)}'); so your object wont be called by ToString but rather JSON.stringify will work first.

What does object @object mean

The @ sign can be thought of as "escape" character of sorts. Since object is a keyword in C#, you cannot use it as a variable name. However prefix it with an @ character and it no longer is a keyword, just a valid variable name!

Getting [object, Object] instead of whole user data. What does that mean?

Try it,

console.log(user);
console.log(JSON.stringify(user));
console.log("User form the login check" +user);

and write the result for us.



Related Topics



Leave a reply



Submit