Merge pull request #3113 from leviding/patch-2
feat: improve type conversion for string with whitespace
This commit is contained in:
commit
caaa05baeb
1 changed files with 2 additions and 2 deletions
|
@ -70,7 +70,7 @@ Numeric conversion rules:
|
||||||
|`undefined`|`NaN`|
|
|`undefined`|`NaN`|
|
||||||
|`null`|`0`|
|
|`null`|`0`|
|
||||||
|<code>true and false</code> | `1` and `0` |
|
|<code>true and false</code> | `1` and `0` |
|
||||||
| `string` | Whitespaces from the start and end are removed. If the remaining string is empty, the result is `0`. Otherwise, the number is "read" from the string. An error gives `NaN`. |
|
| `string` | Whitespaces (includes spaces, tabs `\t`, newlines `\n` etc.) from the start and end are removed. If the remaining string is empty, the result is `0`. Otherwise, the number is "read" from the string. An error gives `NaN`. |
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ The conversion follows the rules:
|
||||||
|`undefined`|`NaN`|
|
|`undefined`|`NaN`|
|
||||||
|`null`|`0`|
|
|`null`|`0`|
|
||||||
|<code>true / false</code> | `1 / 0` |
|
|<code>true / false</code> | `1 / 0` |
|
||||||
| `string` | The string is read "as is", whitespaces from both sides are ignored. An empty string becomes `0`. An error gives `NaN`. |
|
| `string` | The string is read "as is", whitespaces (includes spaces, tabs `\t`, newlines `\n` etc.) from both sides are ignored. An empty string becomes `0`. An error gives `NaN`. |
|
||||||
|
|
||||||
**`Boolean Conversion`** -- Occurs in logical operations. Can be performed with `Boolean(value)`.
|
**`Boolean Conversion`** -- Occurs in logical operations. Can be performed with `Boolean(value)`.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue