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 || {} means in javascript?
parent.auth || {}
means if parent.auth
is undefined, null or false in boolean case then new empty object will be initialized and assigned.
or you can understand it like:
var auth;
if(parent.auth){
auth=parent.auth;
} else {
auth={};
}
Related Topics
Check If an Element Is Present in an Array
Make Several Requests to an API That Can Only Handle 20 Request a Minute
Get the Index of the Object Inside an Array, Matching a Condition
Equivalent of String.Format in Jquery
Is Node.Js Native Promise.All Processing in Parallel or Sequentially
What Does $(Function() {} ); Do
Setting Query String Using Fetch Get Request
How to Convert Blob to File in JavaScript
How to Set Time Delay in JavaScript
JavaScript - Cannot Set Property of Undefined
How to Set Default Homepage in Ff and Chrome via JavaScript
Optional Chaining in JavaScript
Three.Js Generate Uv Coordinate
Functions That Return a Function