Definition

if (!String.prototype.format) {
    String.prototype.format = function () {
        var args = arguments;
        return this.replace(/{(\d+)}/g, function (match, number) {
            return typeof args[number] != 'undefined'
              ? args[number]
              : match;
        });
    };
}

 

Example

"{0} {1} ".format("a","b");

 

相关文章:

  • 2021-10-19
  • 2021-10-13
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2021-06-24
  • 2021-06-15
猜你喜欢
  • 2021-06-10
  • 2021-06-25
  • 2021-09-29
  • 2022-01-01
  • 2021-11-03
  • 2022-12-23
相关资源
相似解决方案