JavaScript console info() Method

JavaScript console info() method is used to output an informational message to the Web console. In Firefox, a small “i” icon is next to these items in the Web console’s log.

Syntax

info(obj1, msg, subst1, /* …, */ substN)

Parameters

  1. obj1 … objN: It is a list of JavaScript objects to output. The string representations of each object are appended together in the order listed and output.
  2. msg: It is a JavaScript string containing zero or more substitution strings.
  3. subst1 … substN: JavaScript objects to replace substitution strings within msg. This gives you additional control over the format of the output.

Return value

It returns None (undefined).

Example 1: Basic usage

console.info("This is a basic informational message.");

Output

JavaScript console info()

Example 2: Displaying Variables

let name = "Alice";
let age = 30;

console.info("Name:", name);
console.info("Age:", age);

Output

Displaying Variables using console.info() method

Example 3: Displaying Objects and Arrays

let person = {
  firstName: "John",
  lastName: "Doe",
  age: 25,
  isStudent: true
};

let fruits = ["apple", "banana", "cherry"];

console.info("Person Object:", person);
console.info("Fruits Array:", fruits);

Output

Displaying Objects and Arrays using the console.info()

Browser Compatibility

Chrome IE Edge Firefox Safari Opera
Yes 8-11 Yes Yes Yes Yes

That’s it!

Related posts

JavaScript console debug()

JavaScript console clear()

JavaScript console log()

JavaScript console assert()

JavaScript console error()