What is console.log
? What is it used for in jQuery?
jQuery and console. log are unrelated entities, although useful when used together. If you use a browser's built-in dev tools, console. log will log information about the object being passed to the log function. If the console is not active, logging will not work, and may break your script.
The console. log() is a function in JavaScript which is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user.
Answer 505b42d70d4e860002000188console. log() is a function used to print information to the console. return on the other hand is a call to pass some value back up to where the call was made.
The console. log() method outputs a message to the web console. The message may be a single string (with optional substitution values), or it may be any one or more JavaScript objects. Note: This feature is available in Web Workers.
jQuery and console.log
are unrelated entities, although useful when used together.
If you use a browser's built-in dev tools, console.log
will log information about the object being passed to the log
function.
If the console is not active, logging will not work, and may break your script. Be certain to check that the console exists before logging:
if (window.console) console.log('foo');
The shortcut form of this might be seen instead:
window.console&&console.log('foo');
There are other useful debugging functions as well, such as debug
, dir
and error
. Firebug's wiki lists the available functions in the console api.
It has nothing to do with jQuery, it's just a handy js method built into modern browsers.
Think of it as a handy alternative to debugging via window.alert()
it will print log messages in your developer console (firebug/webkit dev tools/ie dev tools)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With