Javascript sprintf function

Many times you want to use a string as a template and do a replace just like you do it with sprintf function in PHP. Unfortunately, javascript don't provide a sprintf function. But, since any string is a String object type, we can extend it and add our own sprintf functionality.

Using the following example that you can test it on JsFiddle you'll have your own sprintf (format named here) function: