console: log() static method

Note: This feature is available in Web Workers.

The console.log() static method outputs a message to the console. The message may be a single string (with optional substitution values), or it may be any one or more JavaScript objects.


log(obj1, /* …, */ objN)
log(msg, subst1, /* …, */ substN)



A list of JavaScript objects to output. Objects are output in the order listed. Please be warned that if you log objects in the latest versions of Chrome and Firefox, what you get logged on the console is a reference to the object, which is not necessarily the 'value' of the object at the moment in time you call console.log(), but it is the value of the object at the moment you open the console.


A JavaScript string containing zero or more substitution strings.


JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.

See Outputting text to the console in the documentation of console for details.

Return value

None (undefined).

Logging objects

Information about an object is lazily retrieved. This means that the log message shows the content of an object at the time when it's first viewed, not when it was logged. For example:

const obj = {};
obj.prop = 123;

This will output {}. However, if you expand the object's details, you will see prop: 123.

If you are going to mutate your object and you want to prevent the logged information from being updated, you can deep-clone the object before logging it. A common way is to JSON.stringify() and then JSON.parse() it:


There are other alternatives that work in browsers, such as structuredClone(), which are more effective at cloning different types of objects.


Console Standard
# log

Browser compatibility

BCD tables only load in the browser

See also