Passing a number as an argument

If the number is passed to the function console.log() then the function will display it.

Example: 

javascript
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

Similar Reads

1. Passing a number as an argument

If the number is passed to the function console.log() then the function will display it....

2. Passing a string as an argument

If the string is passed to the function console.log(), then the function will display it....

3. Passing a char as an argument

If the char is passed to the function console.log(), then the function will display it....

4. Passing a message as an argument

If the message is passed to the function console.log(), then the function will display the given message....

5. Passing a function as an argument

If the function is passed to the function console.log(), then the function will display the value of the passed function....

6. Passing a number with the message as an argument

If the number is passed to the function console.log(), then the function will display it along with the given message....

7. Passing a string with the message as an argument

If the string is passed to the function console.log(), then the function will display it along with the given message....

8. Passing a char with the message as an argument

If the char is passed to the function console.log(), then the function will display it along with the given message....