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. Answer from carcigenicate on reddit.com
🌐
W3Schools
w3schools.com › jsref › met_console_log.asp
JavaScript console.log() Method
❮ Previous ❮ Console Object Reference Next ❯ ... More examples below. The log() method writes (logs) a message to the console.
🌐
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.
Discussions

javascript - How can I see the output of console.log()? - Stack Overflow
I am using this code: How can I see the output of console.log()? I searched on Google but did not find a solu... More on stackoverflow.com
🌐 stackoverflow.com
jquery - Console.log messages not showing up in Chrome's javascript console? - Stack Overflow
I am logging using the jQuery.log plugin (which logs to console.log if available) and I am not seeing any of the logging messages appear in the Chrome JavaScript console. Logging works on Firebug's More on stackoverflow.com
🌐 stackoverflow.com
javascript - How can I make console.log show the current state of an object? - Stack Overflow
In Safari with no add-ons (and actually most other browsers), console.log will show the object at the last state of execution, not at the state when console.log was called. I have to clone the obj... More on stackoverflow.com
🌐 stackoverflow.com
How to read from Chrome's console in JavaScript - Stack Overflow
I know I can keep a variable around ... console.log also append the message to that variable but I am trying to keep the memory consumption of the app low so it would be much more efficient just to grab it from the console. Is there a way to retrieve the console messages from javascript... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/learnprogramming › javascript newbie - what is console.log() actually for??
r/learnprogramming on Reddit: JavaScript newbie - what is console.log() actually for??
September 28, 2021 -

Sorry this may be a dumb question- but I’m learning JavaScript. When do you ACTUALLY need console.log() ? I’m confused about it since we can use Var or let for stating variables . What’s the actual importance of console.log()

🌐
Codecademy
codecademy.com › forum_questions › 5136b02c59407b556b000fae
Explain to me EXACTLY "what is a console log" | Codecademy
It’s basically a command or a instruction through your code for the Console.log(“Thing you put here”) to be implemented to the the console, which is where you’d see “thing you put here”, So MrFutureCoder, in basic terms was right, but i presumed you wanted a more detailed explanation. ... I just started with JavaScript programming a few days ago so I might be wrong.
🌐
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 - Otherwise, do use console.log or any language equivalent and stay away from heavy-handed logging frameworks. ... These are some really useful tips! Nice work. For anyone interested in Chrome DevTools tips, I've posted loads here: umaar.com/dev-tips/ ... Uhhh interesting article... ti bad Javascript doesnt show up on firecode will get by as I learn a bit of Java !
🌐
Bugfender
bugfender.com › blog › javascript-console-log
JavaScript console.log() Method: Complete Guide with Examples | Bugfender
3 weeks ago - console.log() is a foundational tool for developers learning JavaScript. It sends messages to the browser’s DevTools console, so we can
Find elsewhere
🌐
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.
🌐
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 - To do this, we use %c to specify that we have styles to add. The styles get passed into the second argument of the log. console.log("%c This is yellow text on a blue background.", "color:yellow; background-color:blue")
🌐
Node.js
nodejs.org › api › console.html
Console | Node.js v26.4.0 Documentation
The node:console module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers. The module exports two specific components: A Console class with methods such as console.log(), console.error(), and console.warn() that can be used to write to any Node.js stream.
🌐
Datadog
datadoghq.com › blog › monitor-javascript-console-logs
Monitor JavaScript console logs and user activity with Datadog | Datadog
July 19, 2019 - With Datadog’s client-side logging library, you can automatically track JavaScript console errors in real time, and ensure that these issues don’t impair user experience (e.g., a button doesn’t function properly) or revenue-driving initiatives (e.g., an advertisement fails to load).
🌐
Microsoft Learn
learn.microsoft.com › en-us › microsoft-edge › devtools › console › console-log
Log messages in the Console tool - Microsoft Edge Developer documentation | Microsoft Learn
Output is displayed in the Console, below the code that you entered. Instead of logging text values, you can send any valid JavaScript or DOM references to the Console. The Console appropriately displays the various types of JavaScript values that you send to it from console log messages.
🌐
Medium
medium.com › @s.atmaramani › understanding-console-methods-log-warn-debug-in-javascript-8275831f4251
Understanding console Methods (log, warn, debug) in JavaScript | by Sam Atmaramani | Medium
March 3, 2025 - Understanding console Methods (log, warn, debug) in JavaScript JavaScript’s console object provides powerful methods to debug, monitor, and display information in your applications. Among them …
🌐
Medium
medium.com › @trig79 › javascript-the-early-lessons-console-log-and-its-many-siblings-cca77d508738
JavaScript The Early Lessons: console.log() and its many siblings | by Trig | Medium
April 29, 2022 - In this article, I have covered some of the more useful console logging commands, but there are 22 in total which includes clear(), count(), dir(), time(), trace() . As always I encourage you to do your own research and if you wish to learn more about logging then check out the docs at MDN. I hope this has shown you some useful but lesser-known commands which aren’t regularly covered in tutorials. ... The purpose of these articles is not to get bogged down in overly complex examples, I’m sharing my experiences from the point of view of a Jr Dev with others on a similar level. These are the lessons I have learnt that I wish someone had told me about when I first started learning JavaScript.
🌐
DEV Community
dev.to › lissy93 › fun-with-consolelog-3i59
Fun with console.log() 💿 - DEV Community
December 9, 2022 - 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 ...
Top answer
1 of 6
151

You can't. What's in the console can't be read from JavaScript.

What you can do is hook the console.log function so that you store when it logs :

console.stdlog = console.log.bind(console);
console.logs = [];
console.log = function(){
    console.logs.push(Array.from(arguments));
    console.stdlog.apply(console, arguments);
}

console.logs contains all what was logged. You can clean it at any time by doing console.logs.length = 0;.

You can still do a standard, non storing, log by calling console.stdlog.

2 of 6
43

get all console data

how to read browser console error in js?

How to read from Chrome's console in JavaScript

https://www.quora.com/How-do-I-read-console-window-errors-from-Chrome-using-JavaScript

logs

console.defaultLog = console.log.bind(console);
console.logs = [];
console.log = function(){
    // default &  console.log()
    console.defaultLog.apply(console, arguments);
    // new & array data
    console.logs.push(Array.from(arguments));
}

error

console.defaultError = console.error.bind(console);
console.errors = [];
console.error = function(){
    // default &  console.error()
    console.defaultError.apply(console, arguments);
    // new & array data
    console.errors.push(Array.from(arguments));
}

warn

console.defaultWarn = console.warn.bind(console);
console.warns = [];
console.warn = function(){
    // default &  console.warn()
    console.defaultWarn.apply(console, arguments);
    // new & array data
    console.warns.push(Array.from(arguments));
}

debug

console.defaultDebug = console.debug.bind(console);
console.debugs = [];
console.debug = function(){
    // default &  console.debug()
    console.defaultDebug.apply(console, arguments);
    // new & array data
    console.debugs.push(Array.from(arguments));
}
🌐
SheCodes
shecodes.io › athena › 75384-what-is-console-log-and-how-does-it-work
[JavaScript] - What is console.log and how does it work - | SheCodes
Learn about the built-in JavaScript function console.log and how it can be used for debugging and outputting values to the console.