Formatting Strings
When you’re handling string data, you commonly need to format strings quickly. Node.js provides a rudimentary string formatting method in the util module that handles many string formatting needs. The util.format() function accepts a formatter string as the first argument and returns a formatted string. The following is the syntax for the format() method, where format is the formatter string and [...] represents the arguments that follow:
util.format(format, [...])
The format argument is a string that can contain zero or more placeholders. Each placeholder begins with a % character and is eventually replaced with the converted string value from its corresponding argument. The first formatter placeholder represents the second ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access