Created
July 3, 2014 08:01
-
-
Save kiinlam/3f8d53279f2151aff371 to your computer and use it in GitHub Desktop.
str_replace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var printf = function (tmpl) { | |
var i = 1, args = arguments, l = args.length; | |
return tmpl.replace(/%s/g, function () { | |
return (i < l ? args[i++] : ''); | |
}); | |
} | |
printf('%s:%s!', 'test', 'woo!'); // test:woo!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment