Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
doc: combine mentions on excessive arguments
Rephrased how excessive arguments to the format string are concatenated.

Fixes: #13908
  • Loading branch information
nattelog committed Jul 1, 2017
commit 5f01b7b0e22bd7573e1a7a4671d4bd75bfba5c43
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