New issue
Advanced search Search tips

Issue 820064 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Mar 2018
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug



Sign in to add a comment

parseInt faild "2018-3-7".split('-').map(parseInt)

Reported by tblon...@gmail.com, Mar 8 2018

Issue description

Chrome Version (from the about:version page): Version 61.0.3163.100 (Offizieller Build) (64-Bit)
Is this the most recent version:
OS + version: Opensuse 42.2
CPU architecture (32-bit / 64-bit): 64-bit
Window manager:
URLs (if relevant):
Behavior in Linux Firefox:
Behavior in Windows Chrome (if you have access to it):

What steps will reproduce the problem?

in the console

"2018-3-7".split('-').map(function(x){return parseInt(x)})
(3) [2018, 3, 7] working

"2018-3-7".split('-').map((x) => {return parseInt(x)} )
(3) [2018, 3, 7] working

"2018-3-7".split('-').map((x) => parseInt(x))
(3) [2018, 3, 7] working

1: "2018-3-7".split('-').map(parseInt)
   (3) [2018, NaN, NaN] ??? not working
2:  "2018-3-7-6-7-8-9-0-555-4-3-3-4-65".split('-').map(parseInt)

What is the expected result?
1: (3) [2018, 3, 7]

2: (14) [2018, 3, 7, 6, 7, 8, 9, 0, 555, 4, 3, 3, 4, 65]

What happens instead?
1: (3) [2018, NaN, NaN]

2: (14) [2018, NaN, NaN, NaN, NaN, NaN, NaN, 0, 365, 4, 3, 3, 4, 83]



Please provide any additional information below. Attach a screenshot
and backtrace if possible.

For graphics-related bugs, please copy/paste the contents of the about:gpu
page at the end of this report.

 

Comment 1 by woxxom@gmail.com, Mar 8 2018

This is working as intended.
See https://bugs.chromium.org/p/v8/issues/detail?id=2402

    Not a bug, just a JavaScript "feature".
    arr.map(parseInt) calls parseInt as parseInt(arr[i], i). 
    So the index in the array is interpreted as the radix by parseInt.
    Hence the NaNs when the radix is 1 or 2.
Status: WontFix (was: Unconfirmed)

Sign in to add a comment