- Node.js Tutorial
- Node.js - Home
- Node.js - Introduction
- Node.js - Environment Setup
- Node.js - First Application
- Node.js - REPL Terminal
- Node.js - Command Line Options
- Node.js - Package Manager (NPM)
- Node.js - Callbacks Concept
- Node.js - Upload Files
- Node.js - Send an Email
- Node.js - Events
- Node.js - Event Loop
- Node.js - Event Emitter
- Node.js - Debugger
- Node.js - Global Objects
- Node.js - Console
- Node.js - Process
- Node.js - Scaling Application
- Node.js - Packaging
- Node.js - Express Framework
- Node.js - RESTFul API
- Node.js - Buffers
- Node.js - Streams
- Node.js - File System
- Node.js MySQL
- Node.js - MySQL Get Started
- Node.js - MySQL Create Database
- Node.js - MySQL Create Table
- Node.js - MySQL Insert Into
- Node.js - MySQL Select From
- Node.js - MySQL Where
- Node.js - MySQL Order By
- Node.js - MySQL Delete
- Node.js - MySQL Update
- Node.js - MySQL Join
- Node.js MongoDB
- Node.js - MongoDB Get Started
- Node.js - MongoDB Create Database
- Node.js - MongoDB Create Collection
- Node.js - MongoDB Insert
- Node.js - MongoDB Find
- Node.js - MongoDB Query
- Node.js - MongoDB Sort
- Node.js - MongoDB Delete
- Node.js - MongoDB Update
- Node.js - MongoDB Limit
- Node.js - MongoDB Join
- Node.js Modules
- Node.js - Modules
- Node.js - Built-in Modules
- Node.js - Utility Modules
- Node.js - Web Module
- Node.js Useful Resources
- Node.js - Quick Guide
- Node.js - Useful Resources
- Node.js - Dicussion
NodeJS - console.debug() Method
The Node.js console.debug() function is used to print information to stdout in a new line. It works the same as the console.log() method of node.js. This is useful for troubleshooting or understanding how a particular section of code works. Now let's look into the syntax of the console.debug() method.
The Node.js console.debug() of node.js is an inbuilt method of the Console class.
Syntax
Following is the syntax of Node.js console.debug() method −
console.debug(data, args);
Parameters
This method accepts two parameters. The same are described below.
data − This parameter specifies the information that print on the screen.
args − This is an optional parameter, where args are passed as substitution values in information passed to data. These args can be accessed by format specifiers.
Return value
This method will not return anything; instead, it prints the formatted information to stdout in a new line similar to the console.log() method.
Example
The Node.js console.debug() method works similarly to the Node.js console.log() method. This method accepts a parameter (data).
In this example, we are calling the console.debug() method with only a data parameter.
const console = require('console'); console.debug('Tutorialspoint'); console.debug('Simply Easy Learning at your fingertips...');
Output
As we can see in the output, the message we passed as a data parameter is printed to stdout in a new line. Similar to the console.log() method of node.js.
Tutorialspoint Simply Easy Learning at your fingertips...
Example
The console.debug() method of node.js will accept an optional parameter (args).
In this example, we are calling the console.debug() method with two parameters data and args.
const console = require('console'); console.debug('There are %d pancakes in the refrigerator, 4); console.debug('%s is having a %d pack body', "Nik", 6);
Output
home/cg/root/63a00e1fdca8a/main.js:3 console.debug('There are %d pancakes in the refrigerator, 4); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Invalid or unexpected token at new Script (vm.js:74:7) at createScript (vm.js:246:10) at Object.runInThisContext (vm.js:298:10) at Module._compile (internal/modules/cjs/loader.js:670:28) at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10) at Module.load (internal/modules/cjs/loader.js:612:32) at tryModuleLoad (internal/modules/cjs/loader.js:551:12) at Function.Module._load (internal/modules/cjs/loader.js:543:3) at Function.Module.runMain (internal/modules/cjs/loader.js:744:10) at startup (internal/bootstrap/node.js:238:19)
Note − To get the accurate result, better execute the above code in local.
As we can see in the output, the message we passed as a data parameter and also passed some substitution values in the args parameter is printed to stdout in a newline.
There are 4 pancakes in the refrigerator Nik is having a 6 pack body
To Continue Learning Please Login
Login with Google