Reputation: 3854
I am asp.net developer. I am working on some third party tools that have javascript code.
Like:
"function(s, e) { alert(e) }; "
If i wrote e then it return as an object.
How can i find the properties of this object?
Is there some easy way/ may be using Firebug etc.
Any Ideas?
Upvotes: 0
Views: 124
Reputation: 179046
console.log
will log a message to the console. With Firebug and the chrome developer tools this will often provide an interactive interface into the object's properties. If the object is array-like, consoles will often display it as ['val1', 'val2', ...]
instead of {'key': 'value'}
.
console.log
can take multiple arguments, so you're better off separating values as:
console.log('Foo:', foo, 'Bar:', bar);
rather than trying to use string concatenation, which would ruin the interactivity of the console.
Additionally, DOM elements in the nicer consoles can often be hovered to highlight where the element occurs on the page.
That all said, DOM elements are often not expandable in the console, which can be inconvenient if you want to explore their properties.
Use console.dir
if you want to force an object to be expandable in the console.
Upvotes: 1
Reputation: 29668
In most debug tools you can just type it into the console to inspect it.
You can also do:
console.log(e);
Upvotes: 2