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 alert
ing 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
JavaScript by Reference Vs. by Value
How to Pad a Value With Leading Zeros
Http Get Request in JavaScript
Onclick or Inline Script Isn't Working in Extension
How to Detect If a Browser Window Is Not Currently Active
How to Do String Interpolation in JavaScript
Looping Through Array and Removing Items, Without Breaking For Loop
Accessing the Web Page'S Http Headers in JavaScript
How to Get Image Size (Height & Width) Using JavaScript
Setstate Doesn't Update the State Immediately
JavaScript Function Scoping and Hoisting
When Should I Use Double or Single Quotes in JavaScript
One-Liner to Take Some Properties from Object in Es 6
What Does the Comma Operator Do in JavaScript