Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorNathan Rajlich <nathan@tootallnate.net>2012-10-06 03:48:13 +0400
committerNathan Rajlich <nathan@tootallnate.net>2012-10-06 03:48:13 +0400
commitf826b3269d62cd64439d68a145eeeb658973740c (patch)
treebb69b7e0d285f8040c3baa53709f3d4474a46a79 /doc
parentfbb0ee6f24cb8679cb7b9de0cdbe9ad80f1363c7 (diff)
doc: document the custom "inspect()" function behavior
Closes #3361.
Diffstat (limited to 'doc')
-rw-r--r--doc/api/util.markdown13
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/api/util.markdown b/doc/api/util.markdown
index 2c1b7634b75..58bbfb7e0ec 100644
--- a/doc/api/util.markdown
+++ b/doc/api/util.markdown
@@ -88,6 +88,19 @@ Example of inspecting all properties of the `util` object:
console.log(util.inspect(util, true, null));
+Objects also may define their own `inspect(depth)` function which `util.inspect()`
+will invoke and use the result of when inspecting the object:
+
+ var util = require('util');
+
+ var obj = { name: 'nate' };
+ obj.inspect = function(depth) {
+ return '{' + this.name + '}';
+ };
+
+ util.inspect(obj);
+ // "{nate}"
+
## util.isArray(object)