What is the use of console.log?
Please explain how to use it in JavaScript, with a code example.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s not a jQuery feature but a feature for debugging purposes. You can for instance log something to the console when something happens. For instance:
You’d then see
#someButton was clickedin Firebug’s “Console” tab (or another tool’s console — e.g. Chrome’s Web Inspector) when you would click the button.For some reasons, the console object could be unavailable. Then you could check if it is – this is useful as you don’t have to remove your debugging code when you deploy to production: