The console.warn() method is used to print a warning message to the web console with a small triangle with an “i” icon displayed next to it. This method comes with a different color in the console tab. By default, the error message displays in yellow color in the console tab.
This is mostly used by NPM packages for angular/react framework to inform developers if the particular library or the API/version is deprecated or about any future changes to the library. Some web browsers add a small exclamation mark in the web console for warnings indication.
- message – This parameter contains the warning message to write to the web console.
What we discussed above is given in the below example.
Output: Press F12 and go to the Console section