We are looking for output formatting (functionality like sprintf) in node.js, but before I write it myself, I was wondering if there was something like this built-in (I was wasting documents to no avail) or if someone had already written a module.
Thank you very much
Now, util.format() has printf -like support.
util.format()
printf
Example:
util.format('hello %s', 'world'); // Returns: 'hello world'
There are a couple in the npm registry:
Here is the javascript sprintf version:
sprintf
http://phpjs.org/functions/sprintfโบ22
console.log works fine.
console.log
console.log('%d hours', 4); // 4 hours console.log('The %2$s contains %1$d monkeys', 4, 'tree'); // The tree contains 4 monkeys