我正在寻找一个很好的JavaScript等价的C/PHP printf()或C#/ Java程序员String.Format()(IFormatProvider对于.NET).
我的基本要求是现在有一千个数字分隔符格式,但处理许多组合(包括日期)的东西会很好.
我意识到Microsoft的Ajax库提供了一个版本String.Format(),但我们不希望该框架的整个开销.
我有以下javascript代码片段:
var someValue = 100;
var anotherValue = 555;
alert('someValue is {0} and anotherValue is {1}'.format(someValue, anotherValue));
Run Code Online (Sandbox Code Playgroud)
得到以下错误:
Uncaught TypeError: undefined is not a function
Run Code Online (Sandbox Code Playgroud)
我错过了什么,这里?