0

I have some expressions which behave in a strange way:

"600x400".split('x').map(parseInt)
"600x400".split('x').map(parseFloat)

And

"0,1,0,0,0,1".split(',').map(parseInt)
"0,1,0,0,0,1".split(',').map(parseFloat)

Applying parseInt to the arrays of strings makes the second element NaN while parseFloat gives the right number.

Bug in JavaScript ?

1 Answers1

0

Using arrow function :

"600x400".split('x').map( x => parseInt(x))
[ 600, 400 ]
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223