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:

$('#someButton').click(function() {
  console.log('#someButton was clicked');
  // do something
});

You'd then see #someButton was clicked in 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:

if (window.console && window.console.log) {
  // console is available
}
Answer from Jan Hančič on Stack Overflow
🌐
freeCodeCamp
freecodecamp.org › news › javascript-console-log-example-how-to-print-to-the-console-in-js
JavaScript Console.log() Example – How to Print to the Console in JS
November 12, 2024 - If we were to change isItWorking to true, then the message will not be logged. ... Each iteration of this loop will print a count to the console.
🌐
W3Schools
w3schools.com › jsref › met_console_log.asp
JavaScript console.log() Method
The log() method is useful for testing purposes. When testing console methods, be sure to have the console view visible. Press F12 to open the console veiw. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want to make a suggestion, send us an e-mail: help@w3schools.com · HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial
Discussions

javascript - What is console.log? - Stack Overflow
What is the use of console.log? Please explain how to use it in JavaScript, with a code example. More on stackoverflow.com
🌐 stackoverflow.com
Use console.log() like a pro
Quick reminder: Logging a JavaScript object to the console isn't logging that object's state, it is logging an object reference. So for example: var x = {H: 'Hello', W: 'World'}; console.log(x); x.H = ''; x.W = ''; If you put in a breakpoint right after the .log line you could get the object's state at the time of log (but then you don't need the log line anyway), but if you just let this run then inspect x in the console after you will get the object's updated state (H: '', W: ''). This is working as intended. It is a known limitation you should be aware of. If you want a stateful object via logging the easiest way to get it is via: console.log(JSON.parse(JSON.stringify(obj))); This is a hack to clone the object and log that instead. More on reddit.com
🌐 r/programming
157
1646
April 11, 2021
JavaScript newbie - what is console.log() actually for??
It's for sending data to the console to be viewed by a developer, or potentially an end user for remote diagnostic purposes. It's used specifically for logging (as the method name suggests), and debugging. If you know other languages, console.log is essentially JS's version of print/println. If you've never seen the browser console before, open your browser, hit F12 to open the developer tools, then press the "console" tab. You can run arbitrary JS in that window, and logs will show up there. I’m confused about it since we can use Var or let for stating variables . console.log has nothing to do with var or let or variables; beyond that it allows printing the contents of variables. More on reddit.com
🌐 r/learnprogramming
7
7
September 28, 2021
How to display the console.log result in HTML?
Well, you don't, and normally shouldn't be trying to. console.log is not intended to display anything on the page, there are other ways for that. You'd have an element on the website and simply set its innerText property to the value you want it to display, something like document.getElemenetById("result").innerText = value. More on reddit.com
🌐 r/learnjavascript
44
14
December 8, 2022
🌐
Bugfender
bugfender.com › blog › javascript-console-log
JavaScript console.log() Method: Complete Guide with Examples | Bugfender
3 weeks ago - Here’s an example that shows both styling and value substitution: console.log( '%c I have %d %s', 'color: green; background:black; font-size: 20pt', 3, 'Bikes!' ) ... Using %c helps us visually separate labels from values, highlight dynamic ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › console › log_static
console: log() static method - Web APIs | MDN
console.log(val1) console.log(val1, /* …, */ valN) console.log(msg) console.log(msg, subst1, /* …, */ substN) ... A list of JavaScript values to output. A representation of each of these values is output to the console in the order given with some type of separation between each of them.
🌐
Programiz
programiz.com › javascript › console
JavaScript console.log()
let message = "Hello, JavaScript!"; console.log(message); // Output: Hello, JavaScript!
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-console-log-method
JavaScript console.log() Method - GeeksforGeeks
September 2, 2025 - Message can be a string, number, object, array, or any valid JavaScript expression. It returns the value of the parameter given. The console.log() method is one of the most widely used debugging tools in JavaScript.
🌐
Pi My Life Up
pimylifeup.com › home › using console.log() in javascript
Using console.log() in JavaScript - Pi My Life Up
August 20, 2022 - The entire object structure is logged to the console when logging an object. To showcase logging objects, we will start our example by declaring an object using the const keyword with the name “website. After declaring the variable we will pass the object into JavaScript’s “console.log()” ...
Find elsewhere
Top answer
1 of 16
463

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:

$('#someButton').click(function() {
  console.log('#someButton was clicked');
  // do something
});

You'd then see #someButton was clicked in 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:

if (window.console && window.console.log) {
  // console is available
}
2 of 16
227

Places you can view the console! Just to have them all in one answer.

Firefox

http://getfirebug.com/

(you can also now use Firefox's built in developer tools Ctrl+Shift+J (Tools > Web Developer > Error Console), but Firebug is much better; use Firebug)

Safari and Chrome

Basically the same.

https://developers.google.com/chrome-developer-tools/docs/overview

https://developer.apple.com/technologies/safari/developer-tools.html

Internet Explorer

Don't forget you can use compatibility modes to debug IE7 and IE8 in IE9 or IE10

http://msdn.microsoft.com/en-us/library/ie/gg589507(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/dd565628(v=vs.85).aspx

If you must access the console in IE6 for IE7 use the Firebug Lite bookmarklet

http://getfirebug.com/firebuglite/ look for stable bookmarklet

http://en.wikipedia.org/wiki/Bookmarklet

Opera

http://www.opera.com/dragonfly/

iOS

Works for all iPhones, iPod touch and iPads.

http://developer.apple.com/library/ios/ipad/#DOCUMENTATION/AppleApplications/Reference/SafariWebContent/DebuggingSafarioniPhoneContent/DebuggingSafarioniPhoneContent.html

Now with iOS 6 you can view the console through Safari in OS X if you plug in your device. Or you can do so with the emulator, simply open a Safari browser window and go to the "Develop" tab. There you will find options to get the Safari inspector to communicate with your device.

Windows Phone, Android

Both of these have no console built in and no bookmarklet ability. So we use http://jsconsole.com/ type :listen and it will give you a script tag to place in your HTML. From then on you can view your console inside the jsconsole website.

iOS and Android

You can also use http://html.adobe.com/edge/inspect/ to access web inspector tools and the console on any device using their convenient browser plugin.


Older browser problems

Lastly older versions of IE will crash if you use console.log in your code and not have the developer tools open at the same time. Luckily it's an easy fix. Use the below code snippet at the top of your code:

 if(!window.console){ window.console = {log: function(){} }; } 

This checks to see if the console is present, and if not it sets it to an object with a blank function called log. This way window.console and window.console.log is never truly undefined.

🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_console_log.htm
JavaScript - Console.log() Method
In the example below, we have printed the "Hello World!" message using the console.log() method.
🌐
DEV Community
dev.to › ackshaey › level-up-your-javascript-browser-logs-with-these-console-log-tips-55o2
Level up your JavaScript browser logs with these console.log() tips - DEV Community
June 18, 2021 - Lastly, if you’re new to JavaScript and want to understand how object-oriented JavaScript and prototypal inheritance work under the hood, check out my favorite book on the subject - The Principles of Object-Oriented JavaScript, and if you’re interested in learning more about why you should use TypeScript instead, check out Effective TypeScript. ... Console.log()/table()/etc...
🌐
Syncfusion
syncfusion.com › blogs › javascript › 11 console methods in javascript for effective debugging
11 Console Methods in JavaScript for Effective Debugging | Syncfusion Blogs
December 10, 2024 - In addition, it logs messages to a debugging terminal instead of presenting them in the browser console. var testVariable = 404; console.log("This is triggered by console.log") console.log("checking the variable value",testVariable) In the example ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › console
console - Web APIs - MDN Web Docs
For example, Safari and Firefox support the C-style precision formatting %.<precision>f. For example console.log("Foo %.2f", 1.1) will output the number to 2 decimal places: Foo 1.10, while console.log("Foo %.2d", 1.1) will output the number as two significant figures with a leading 0: Foo 01.
🌐
Savvy
savvy.co.il › blog › javascript complete guide › mastering javascript console.log()
Mastering JavaScript console.log() | Savvy
February 17, 2026 - let name = 'Bob'; let age = 25; console.log('Name:', name, 'Age:', age); The console supports string substitution for formatted output.
🌐
WsCube Tech
wscubetech.com › resources › javascript › console-log
JavaScript console.log(): Explained With Examples
November 7, 2025 - Learn how to use JavaScript console.log() to debug code, log messages, and simplify development. Master this essential debugging tool for better coding!
🌐
Board Infinity
boardinfinity.com › blog › javascript-console-log-method
JavaScript console.log() Method | Board Infinity
August 9, 2025 - Learn how to use JavaScript’s console.log() method to display messages, debug code, and understand syntax with practical examples.
🌐
DEV Community
dev.to › lissy93 › fun-with-consolelog-3i59
Fun with console.log() 💿 - DEV Community
December 9, 2022 - For example: console.count(NaN); // NaN: 1 console.count(NaN+3); // NaN: 2 console.count(1/0); // Infinity: 1 console.count(String(1/0)); // Infinity: 2 · In JavaScript, we're often working with deeply nested methods and objects. You can use console.trace() to traverse through the stack trace, and output which methods were called to get to a certain point. You can optionally pass data to also be outputted along with the stacktrace. If your logging a large object to the console, it may become hard to read.
🌐
freeCodeCamp
freecodecamp.org › news › console-logging-tips
Console Logging Tips – How to Debug and Understand Your Code
February 20, 2024 - Console logging is a powerful tool for debugging JavaScript code. By leveraging advanced console logging tricks such as console.table, console.group, console.assert, and others, you can streamline your debugging process and gain deeper insights into your code's behavior. In this comprehensive guide, we covered various console logging tricks, along with examples ...
🌐
Dmitri Pavlutin
dmitripavlutin.com › console-log-tips
Handy Tips on Using console.log() - Dmitri Pavlutin
March 18, 2020 - Sometimes you might want a message containing multiple variables. Fortunately, console.log() can format the string in a sprintf() way using specifiers like %s, %i, etc. For example, let's format a message containing a string and an integer:
🌐
BitDegree
bitdegree.org › learn › javascript-console-log
Learn About JavaScript Console Log and How to Print in JavaScript
January 4, 2016 - Take a look at the example and its explanation below:\n\n Example Copy \n\n · This paragraph element has excess spacing and has a span element<\/span> inside.<\/p>\n\nGet innerText<\/button>\nGet innerHTML<\/button>\nGet textContent<\/button>\n\n · 🔥 BitDegree partnered with Ogvio - a free international money transfer service! Join the waitlist & grab Rewards! 🎁 ... Code has been added to clipboard! ... This tutorial on JavaScript console log will teach you different ways of outputting data, such as window.alert(), document.write(), innerHTML, console.log(), and others.
🌐
SheCodes
shecodes.io › athena › 9472-using-console-log-for-debugging-in-javascript
[JavaScript] - Using console.log for Debugging in | SheCodes
Learn how to use console.log for debugging in your JavaScript code. See examples of how to use it to log variables and messages.