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
- JavaScript Math log() Method The JavaScript Math log( ) Method is used to return the natural logarithm (base e) of a number. The JavaScript Math.log() method is equivalent to ln(x) in mathematics. If the value of x is negative, then the math.log() method return NaN. The log() is a static method of Math, therefore, it is always 3 min read
- JavaScript Math log2() Method The Javascript Math.log2() is an inbuilt method in JavaScript that gives the value of base 2 logarithms of any number. Syntax: Math.log2(p)Parameters: This method accepts a single parameter p which is any number whose base 2 logarithms is to be calculated. Returns: It returns the value of base 2 log 3 min read
- JavaScript Handler construct() Method JavaScript handler.construct() method in JavaScript is a trap for the new operation and this method returns an object. Syntax: const p = new Proxy(target, { construct: function(target, argumentsList, newTarget) { } }); Parameters: This method accepts three parameters as mentioned above and described 2 min read
- JavaScript Math log10() Method The Javascript Math.log10() is an inbuilt method in JavaScript that gives the value of base 10 logarithms of any number. Syntax:Math.log10(p)Parameters: This method accepts a single parameter p which is any number whose base 10 logarithms is to be calculated.Return Value: It returns the value of bas 3 min read
- JavaScript Math log1p() Method Javascript Math.log1p() is an inbuilt function in JavaScript that gives the value of the natural logarithm of 1 + p number. The natural logarithm is of base e, where e is an irrational and transcendental number approximately equal to 2.718. Syntax: Math.log1p(1 + p)Below example illustrate the JavaS 4 min read
- JavaScript Helper Methods An array in JavaScript is usually considered a "list-objects". In simple words, we can say an array is an object that contains some values. But an array is a special object in JavaScript. An array can store heterogeneous data structures. It can store data values of any type like objects and array. E 15+ min read
- Console in JavaScript The console object provides access to the browser's debugging console (or terminal in Node.js). It is used to log information, debug code, and interact with the runtime environment during development. Commonly Used console MethodsHere are the most frequently used methods of the console object: 1. co 3 min read
- JavaScript Map forEach() Method JavaScript Map.forEach method is used to loop over the map with the given function and executes the given function over each key-value pair. Syntax:myMap.forEach(callback, value, key, thisArg)Parameters:This method accepts four parameters as mentioned above and described below: callback: This is the 3 min read
- HTML DOM console log() Method The console.log() method in HTML is used for writing a message in the console. It indicates an important message during the testing of any program. The message is sent as a parameter to the console.log() method. Syntaxconsole.log( message )ParametersParameter Description message It is mandatory and 2 min read
- JavaScript Date getSeconds() Method The date.getSeconds() method is used to fetch the seconds from the given Date object according to the local time. The value returned by this method ranges from 0 to 59. Syntax: DateObj.getSeconds()Parameters:This function does not accept any parameter. Return Values: It returns the second for the gi 3 min read