Number Operators
When we need to work with numbers, these operators will help with your markdown.
List of Operators
{{ bytes }}
Format a number to it's equivalent in bytes. If a string is passed, it's length will be formatted and returned.
Examples:
'foo' => 3 B
13661855 => 13.66 MB
825399 => 825.39 kB
1396 => 1.4 kB
Params
number
0returns
{{ addCommas }}
Add commas to numbers
Params
num
returns
Example
{{ phoneNumber }}
Convert a string or number to a formatted phone number.
Params
num
0: The phone number to format, e.g.8005551212
returns
: Formatted phone number:(800) 555-1212
Example
{{ toAbbr }}
Abbreviate numbers to the given number of precision
. This is for
general numbers, not size in bytes.
Params
number
precision
returns
Example
{{ toExponential }}
Returns a string representing the given number in exponential notation.
Params
number
fractionDigits
: Optional. An integer specifying the number of digits to use after the decimal point. Defaults to as many digits as necessary to specify the number.returns
Example
{{ toFixed }}
Formats the given number using fixed-point notation.
Params
number
digits
: (Optional) The number of digits to appear after the decimal point; this may be a value between 0 and 20. If this argument is omitted, it is treated as 0.returns
: A string representing the given number using fixed-point notation.
Example
{{ toFloat }}
Params
number
returns
{{ toInt }}
Params
number
returns
Example
{{ toPrecision }}
Returns a string representing the Number
object to the specified precision.
Params
number
precision
: (Optional) An integer specifying the number of significant digits. If precison is not between 1 and 100 (inclusive), it will be coerced to0
.returns
: A string representing a Number object in fixed-point or exponential notation rounded to precision significant digits.
Example