Instructions for using the console.dir method in node.js

  • 2020-03-30 04:32:39
  • OfStack

Method description:

Pass obj as a parameter to util. Inspect and execute, printing the returned result to stdout.

This function ignores any custom inspect() function object.

Grammar:


console.dir(obj)

Receiving parameters:

Obj            Any object

Example:


console.dir({"a":"1","b":"2","c":"3"})
//Output:
string-like {"a":"1","b":"2","c":"3"}

Source:


Console.prototype.dir = function(object) {
  this._stdout.write(util.inspect(object, { customInspect: false }) + 'n');
};


Related articles: