JavaScript console.log() Method
Last Updated :
09 Jan, 2025
Improve
The console.log() method in JavaScript logs messages or data to the console.
The console.log() method is useful for debugging or testing purposes.
Syntax:
console.log("");
Parameters:
Any message either number, string, array object, etc.
Return value:
It returns the value of the parameter given.
Using Console.log()
Using the console.log() to print a string on the console.
console.log("Hello Geeks")
Output
Hello Geeks
We can even print an array or an object on the console using log() method
Logging a Object and Array
// Logging an Object
const myObject = {Skill1:"HTML", Skill2:"CSS"};
console.log(myObject);
// Logging an array
const myArray = ["HTML", "CSS", "JavaScript"];
console.log(myArray);
Output
{ Skill1: 'HTML', Skill2: 'CSS' } [ 'HTML', 'CSS', 'JavaScript' ]