Skip to content

Commit

Permalink
doc: combine mentions on excessive arguments
Browse files Browse the repository at this point in the history
Rephrased how excessive arguments to the format string are concatenated.

Fixes: nodejs#13908
  • Loading branch information
nattelog committed Jul 1, 2017
1 parent b687f17 commit 5f01b7b
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,16 @@ util.format('%s:%s', 'foo');
// Returns: 'foo:%s'
```

If there are more arguments passed to the `util.format()` method than the
number of placeholders, the extra arguments are coerced into strings (for
objects and symbols, `util.inspect()` is used) then concatenated to the
returned string, each delimited by a space.
If there are more arguments passed to the `util.format()` method than the number
of placeholders, the extra arguments are coerced into strings then concatenated
to the returned string, each delimited by a space. Excessive arguments whose
`typeof` is `'object'` or `'symbol'` (except `null`) will be transformed by
`util.inspect()`.

```js
util.format('%s:%s', 'foo', 'bar', 'baz'); // 'foo:bar baz'
```

Any non-object and non-symbol excessive argument will **not** have
`util.inspect()` called on them.

```js
util.format('%s', 'foo', () => true); // 'foo () => true'
```

If the first argument is not a string then `util.format()` returns
a string that is the concatenation of all arguments separated by spaces.
Each argument is converted to a string using `util.inspect()`.
Expand Down

0 comments on commit 5f01b7b

Please sign in to comment.