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

This is a simple demonstration of the console.info() method.

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 using the console.info()

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() Method

JavaScript console clear() Method

JavaScript console log() Method

JavaScript console assert() Method

JavaScript console error() Method

Leave a Comment