( ) Node.js v0.10.33 ()/v0.11.14 () ( ) v7.7.4 (, ) ,
;
util.inspect() : console.log() console.dir() REPL- util.inspect() Node.js util.inspect() util.inspect(), require('util') util.inspect() .
:
console.dir(myObject, { depth: null }); // 'depth: null' ensures unlimited recursion
.
- REPL:
util.inspect() ;
, Enter, ; :o = { one: 1, two: 'deux', foo: function(){} }//echoes the object definition with syntax coloring.
util.inspect() ( ) , - , 1 .
, JSON.stringify() , :
- , ,
module . - () .
- ( ) .
- :
JSON.stringify({ one: 1, two: 'deux', three: true}, undefined, 2);//creates a pretty-printed multiline JSON representation indented with 2 spaces
util.inspect() (2- ):
: http://nodejs.org/api/util.html#util_util_format_format
, :
showHiddentrue, [, for keys in obj Object.keys(obj) ]. false.
depthcolors- true, ANSI.
false. [... - . ].
customInspectfalse, inspect() , . true.
util.format() (1- )
: http://nodejs.org/api/util.html#util_util_format_format
%s - .%d - ( , ).%j - JSON.% - ('%'). .