sprintf.js icon indicating copy to clipboard operation
sprintf.js copied to clipboard

add printf()?

Open Zorgatone opened this issue 9 years ago • 1 comments

Maybe we could have a printf(...) which would be a wrapper to console.log(sprintf(...)), what do you guys think?

Zorgatone avatar Jul 26 '16 11:07 Zorgatone

@Zorgatone it's literally one line to replicate the C printf behavior including the return value:

var printf = function() { var o = sprintf.apply(sprintf, arguments); console.log(o); return o.length; };
printf("Hello %s!", "World"); // prints 'Hello World!' to console, returns 12

spelunk avatar Nov 10 '16 21:11 spelunk