parseFormat
parseFormat(str)
parseFormat(str)
Parses the input string or number and returns an object containing the sign, base, decimals, and unit components of the string. It provides a structured breakdown of the formatted string for further processing or analysis.
Arguments
str
(string | number
, optional): The input string or number to be parsed. Defaults to "0" if not provided.
Returns
(object)
: An object containing the following properties:sign
(string): The sign of the number ("+" for positive numbers, "-" for negative numbers).base
(string): The base number part of the string.decimals
(number): The number of decimal places in the string.unit
(string): The unit or additional characters in the string.
Example
Usage
Notes
The
parseFormat
function extracts the sign, base, decimals, and unit components of the input string for further analysis or processing.It provides a structured representation of the formatted string, allowing for detailed examination of its components.
The function returns an object with the sign, base, decimals, and unit properties, providing a comprehensive breakdown of the input string.
Last updated
Was this helpful?