JavaScript Console warn() Tutorial

In this section, we will learn what the console warn() method is and how to use it in JavaScript.

JavaScript Console warn() Method

The `warn()` method is used to send warning messages to a browser console.

So when in your program there’s a section that might send an alerting message to users (mainly developers), you can use the `warn()` method.

We set the messages that we want to send to the browser as the arguments for this method.

Usually, browsers put such messages into an orange color box.

Console warn() Method Syntax:

console.warn(message)

Console warn() Method Parameter:

This method takes one or more argument and they are the messages that we want to send to a browser console as a warning.

Console warn() Method Return Value:

This method does not return a value.

Example: using Console warn() method in JavaScript

console.warn("This message is coming from the 'warn' method");

Output:

This message is coming from the 'warn' method
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies