Why [‘1’, ‘7’, ’11’].map(parseInt) returns [1, NaN, 3] in JavaScript
map(parseInt); = [1, NaN, 3]// First iteration: val = ‘1’, index = 0, array = [‘1’, ‘7’, ’11’]parseInt(‘1’, 0, [‘1’, ‘7’, ’11’]); = 1Since 0 is falsy, the radix is set to the default value 10. // Second iteration: val = ‘7’, index = 1, array = [‘1’, ‘7’, ’11’]parseInt(‘7’, 1, [‘1’, ‘7’, ’11’]); = NaNIn a radix 1 system, the symbol ‘7’ does not exist. // Third iteration: val = ’11’, index = 2, array = [‘1’, ‘7’, ’11’]parseInt(’11’, 2, [‘1’, ‘7’, ’11’]); = 3In a radix 2 (binary) system, the symbol ’11’ refers to the number 3.
Source: medium.com