Formats an integer number with dots/commas as thousands separators
-
num:
- Type:
Integer
- Number to format
- Type:
-
separator (optional):
- Type:
String
- Default:
'.'
- Separator
- Type:
globalHelpers.formatNumber(1234567);
//=> '1.234.567'
globalHelpers.formatNumber(1234567, ',');
//=> '1,234,567'
Convert long numbers into a human-readable format, e.g. 25000 to '25K'
-
number:
- Type:
Number
- Number to format
- Type:
-
deciaml (optional):
- Type:
Integer
- Default:
1
- Decimal places
- Type:
globalHelpers.milify(1000);
//=> '1K'
globalHelpers.milify(1000000);
//=> '1M'
globalHelpers.milify(1234567);
//=> '1.23M'
Converts a value to a number if possible.
Acceps an array with numbers to convert
- value:
- Type:
Mix
- The value to convert
- Type:
globalHelpers.toNumber('123');
//=> 123
globalHelpers.toNumber('123.456');
//=> 123.456
globalHelpers.toNumber(['0.123', '1.123', '.13567', '123', '123.54']);
//=> [0.123, 1.123, 0.13567, 123, 123.54]