JavaScript console.log() Method (original) (raw)

Last Updated : 09 Jan, 2025

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.

JavaScript `

console.log("Hello Geeks")

`

We can even print an array or an object on the console using log() method

Logging a Object and Array

JavaScript `

// 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' ]

**Supported Browsers:

Similar Reads