• Node.js Video Tutorials

NodeJS - console.dirxml() Method



The Node.js console.dirxml() method will call the console.log() method at the time of execution by passing the received arguments by dirxml() method. No XML formatting is produced by this method.

Assume there is an object with properties and values. If we pass the object name into the console.dirxml() method, it will call the console.log method by passing the received argument (object). Thus it will show the object's properties in the output.

Syntax

Following is the syntax of the Node.js console.dirxml() method −

console.dirxml(data)

Parameters

  • data − This parameter accepts a JavaScript object or element.

Return value

This method will return the object or element which is been passed.

Example

The Node.js console.dirxml() method will accept only one parameter.

In the example below, we are creating an object with enumerable properties. Then we are passing the object as a parameter to the console.dirxml() method of node.js.

var Family = {
   Husband : "Jack",
   wife : "Rose",
   MarrDuration : "25 years",
   Kids : 1,
   KidName : "Jase",
}
console.dirxml(Family);

Output

As we can see in the output, the family here is an object and we passed it in to console.dirxml() method, then this method will call the console.log() method by passing the received argument.

{
   Husband: 'Jack',
   wife: 'Rose',
   MarrDuration: '25 years',
   Kids: 1,
   KidName: 'Jase'
}

Example

The console.dirxml() method of node.js will accept only one parameter.

In this example, we are passing an integer value as a parameter to the console.dirxml() method of node.js.

var x = 10;
var y = 10;
var z = x + y;
console.dirxml(z);

Output

As we can see in the output, we passed an integer value to the console.dirxml() method and then this method will call the console.log() method by passing the received argument.

20

Example

In this example, we are passing a string as an input to the console.dirxml() method.

console.dirxml("Tutorialspoint, Simply Easy Learning at your fingertips");

Output

As we can see in the output, the input string which is passed as a parameter will be printed.

Tutorialspoint, Simply Easy Learning at your fingertips
nodejs_console_module.htm
Advertisements