Passing a number as an argument
If the number is passed to the function console.log() then the function will display it.
Example:
let a = 2;
console.log(a);
Output:
JavaScript console.log() Method
The console.log() method in JavaScript logs messages or data to the console, facilitating debugging by displaying variable values, object properties, or program flow information.
Syntax:
console.log("");
Parameters:
It accepts a parameter that can be an array, an object, or any message.
Return value: It returns the value of the parameter given.
These are the following ways to use the console.log() method:
Table of Content
- Passing a number as an argument
- Passing a string as an argument
- Passing a char as an argument
- Passing a message as an argument
- Passing a function as an argument
- Passing a number with the message as an argument
- Passing a string with the message as an argument
- Passing a char with the message as an argument