diff options
author | Nathan Rajlich <nathan@tootallnate.net> | 2012-10-05 16:48:13 -0700 |
---|---|---|
committer | Nathan Rajlich <nathan@tootallnate.net> | 2012-10-05 16:48:13 -0700 |
commit | f826b3269d62cd64439d68a145eeeb658973740c (patch) | |
tree | bb69b7e0d285f8040c3baa53709f3d4474a46a79 /doc | |
parent | fbb0ee6f24cb8679cb7b9de0cdbe9ad80f1363c7 (diff) | |
download | nodejs-f826b3269d62cd64439d68a145eeeb658973740c.tar.gz nodejs-f826b3269d62cd64439d68a145eeeb658973740c.tar.bz2 nodejs-f826b3269d62cd64439d68a145eeeb658973740c.zip |
doc: document the custom "inspect()" function behavior
Closes #3361.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/util.markdown | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/doc/api/util.markdown b/doc/api/util.markdown index 2c1b7634b..58bbfb7e0 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) |