Skip to content

parseInt does not work with 0 in mixed string #2191

Closed
@henrythasler

Description

@henrythasler

Action

Execute the following code:

const res = parseInt("0 meters", 10);

see also example in Online-Editor

Expected Behavior

res is 0

Observed Behavior

res is NaN

The false behavior is tied to the number being a 0 ("1 meter" works) and thus I suspect that the requirement

If radix is undefined or 0, it is assumed to be 10 except when the number begins with the code unit pairs 0x or 0X, in which case a radix of 16 is assumed.

is not implemented correctly.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions