I want to share some Javascript prototype functions as below:String.prototype.format = function (n, x, s, c) {
////// Number.prototype.format(n, x, s, c)
/// Example:
/// 12345678.9.format(2, 3, ',', '.'); // "12,345,678.90"
/// 123456.789.format(4, 4, ' ', ':'); // "12 3456:7890"
/// 12345678.9.format(0, 3, '-'); // "12-345-679"
//////length of decimal///length of whole part///sections delimiter///decimal delimiter///var re = '\\d(?=(\\d{' + (x || 3) + '})+' + (n > 0 ? '\\D' : '$') + ')';
// console.log(this.toString());
if (this.toString()) {
v
...
继续阅读
(75)