Skip to content

Instantly share code, notes, and snippets.

@lamnd
Forked from rmariuzzo/sprintf.js
Created November 29, 2019 03:07
Show Gist options
  • Select an option

  • Save lamnd/01ece33eaf46b7bacc5af2855fb51b54 to your computer and use it in GitHub Desktop.

Select an option

Save lamnd/01ece33eaf46b7bacc5af2855fb51b54 to your computer and use it in GitHub Desktop.
Simple and minimal `sprintf` function in JavaScript.
function sprintf(format) {
var args = Array.prototype.slice.call(arguments, 1);
var i = 0;
return format.replace(/%s/g, function() {
return args[i++];
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment