A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/node-js/node-js-console-warn-function/ below:

Node.js console.warn() Function - GeeksforGeeks

Node.js console.warn() Function

Last Updated : 12 Jul, 2025

The

console.warn() function

from console class of

Node.js

is used to display the warning messages on the console. It prints to stderr with newline.

Note:

This function is an alias of console.error() function.

Syntax:
console.warn( [data][, ...args] )
Parameter:

This function can contains multiple parameters. The first parameter is used for the primary message and other parameters are used for substitution values.

Return Value:

The function returns the warning message. Below programs demonstrate the working of the console.warn() function:

Program 1: javascript
function displayWarning(x) {
    console.warn(`GeeksforGeeks is a ${x} portal`);
}
 
const x = 'Computer Science';

displayWarning(x);
Output:
GeeksforGeeks is a Computer Science portal
Program 2: javascript
function compareNumber(x, y) {
    
    // Check condition
    if (x > y) {
        console.warn(`${x} is greater then ${y}`);
    }
    else {
        console.warn(`${x} is less then or equal to ${y}`);
    }
}

// Store number to variable
x = 100;
y = 50;

compareNumber(x, y);
Output:
100 is greater then 50


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4