diff options
author | koichik <koichik@improvement.jp> | 2011-08-23 00:19:39 +0900 |
---|---|---|
committer | koichik <koichik@improvement.jp> | 2011-08-23 01:15:32 +0900 |
commit | 509a676128a250884af2810b62a264298ae172b0 (patch) | |
tree | e203f2159e879c77e09a80cd40ae995d8aeaafca /doc | |
parent | ce9caa237fe730ecf18cc96f4a176352a1b1a2dc (diff) | |
download | nodejs-509a676128a250884af2810b62a264298ae172b0.tar.gz nodejs-509a676128a250884af2810b62a264298ae172b0.tar.bz2 nodejs-509a676128a250884af2810b62a264298ae172b0.zip |
Doc improvements
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/stdio.markdown | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/doc/api/stdio.markdown b/doc/api/stdio.markdown index d4153934e..45d8d3bca 100644 --- a/doc/api/stdio.markdown +++ b/doc/api/stdio.markdown @@ -9,8 +9,30 @@ Prints to stdout with newline. This function can take multiple arguments in a console.log('count: %d', count); -If formating elements are not found in the first string then `util.inspect` -is used on each argument. +The first argument is a string that contains zero or more *placeholders*. +Each placeholder is replaced with the converted value from its corresponding +argument. Supported placeholders are: + +* `%s` - String. +* `%d` - Number (both integer and float). +* `%j` - JSON. + +If the placeholder does not have a corresponding argument, `undefined` is used. + + console.log('%s:%s', 'foo'); // 'foo:undefined' + +If there are more arguments than placeholders, the extra arguments are +converted to strings with `util.inspect()` and these strings are concatenated, +delimited by a space. + + console.log('%s:%s', 'foo', 'bar', 'baz'); // 'foo:bar baz' + +If the first argument is not a format string then `console.log()` prints +a string that is the concatenation of all its arguments separated by spaces. +Each argument is converted to a string with `util.inspect()`. + + console.log(1, 2, 3); // '1 2 3' + ### console.info() |