title: sprintf equivalent for client-side JavaScript
body: <p>I know that <code>console.log</code> supports at least some of the basic features of <code>printf</code> from C through messing around, but I was curious of a way to take advantage of <code>console.log</code>'s implementation to create something similar to <code>sprintf</code>. I know you can't simply use <code>.bind</code> or <code>.apply</code> since <code>console.log</code> doesn't actually return the string, so is there a way around this?</p>
  
  <p>If this isn't actually possible, is there some other little-known native implementation that's only a few lines of code away from achieving <code>sprintf</code> in JavaScript?</p>
  
  <p>For those who do not know what <code>sprintf</code> is exactly, <a href="http://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm" rel="nofollow">here is some documentation from tutorialspoint</a>. Example usage I'm looking for is below:</p>
  
  <pre><code>var string1 = sprintf("Hello, %s!", "world");
  var string2 = sprintf("The answer to everything is %d.", 42);
  </code></pre>