console.log() (JavaScript)
console.log() prints a message to the browser's (or Node's) developer console. It is the main tool for inspecting values and debugging JavaScript.
JavaScript
console.log() is JavaScript's equivalent of Python's print() and Java's System.out.println(). You can pass it any number of values — strings, numbers, arrays, objects — and it shows them in the console.
Developers use it constantly to check what a variable contains while a program runs.
Syntax
console.log(value1, value2, ...)Examples
JavaScript
console.log("Hello, world!");Output:
Hello, world!JavaScript
const user = { name: "Ana", age: 30 };
console.log(user.name, user.age);Output:
Ana 30