ElegyOfDisaster/web/stringFormat.js
2018-06-01 01:44:47 +08:00

4 lines
200 B
JavaScript

/* https://stackoverflow.com/questions/610406/javascript-equivalent-to-printf-string-format */
String.prototype.format = function(array) {
return array.reduce((p,c) => p.replace('{}',c), this);
};