views:

76

answers:

3

Hello,

I come from PHP background and am used to doing var_dump, echo and print_r while doing some kind of debugging.

I have just started on jquery, today is my first day infact and am trying to see if there is a way to dump out value to firebug console.

Do we have similar function to var_dump or echo in jQuery or any other way to get values or debug statements displayed on the console ?

+5  A: 

Please use Console.log()

http://getfirebug.com/logging

HTH

Raja
I am not sure if this would work as I need to see if particular function is called or not and so in that particular function am using echo or print statement and so please explain about console.log thing, do I need to put console.log into my function ?
Rachel
Its exactly what you want. but instead of `echo $var;` like you'd do in PHP, in your javascript you write `console.log(var_name);`
Stomped
I am doing that way only but still it is not printing the values in the console of firebug.
Rachel
You'd probably get more help if you posted your actual code
Stomped
A: 

Another alternative would be to use my log4javascript, which has a console that works in all the major browsers and displays a list of properties for any object passed to its logging calls.

Tim Down
Can't I just `echo "Hello"` in my function and see if it gets printed on firebug console to see if am reaching that particular function or not ?
Rachel
`window.console.log("Hello");` will work, as others have said. You do need to make sure Firebug is active at the time: press F12 or click the icon in the bottom of the window.
Tim Down
A: 

To see if a particular function is being called or not, it might be more useful to set a debugger breakpoint instead. See here: http://getfirebug.com/javascript

Dave Ward