parseInt() behaves weirdly when called repeatedly
Reported by
joncaru...@gmail.com,
Jan 24 2018
|
||
Issue descriptionUserAgent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/63.0.3239.84 Chrome/63.0.3239.84 Safari/537.36 Steps to reproduce the problem: ['1', '1'].map(x => parseFloat(x)) ['1', '1'].map(x => parseInt(x)) ['1', '1'].map(parseFloat) ['1', '1'].map(parseInt) What is the expected behavior? [1, 1] [1, 1] [1, 1] [1, 1] What went wrong? [1, 1] [1, 1] [1, 1] [1, NaN] Did this work before? N/A Chrome version: 63.0.3239.84 Channel: stable OS Version: 16.04 Flash Version:
,
Jan 24 2018
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.
,
Jan 24 2018
|
||
►
Sign in to add a comment |
||
Comment 1 Deleted