top | item 39969777

(no title)

fs_tab | 1 year ago

Somewhat related - be wary of implicit parameter passing in function pipelines. For example, Try ['10', '10', '10'].map(Number.parseInt) in your browser console. What's actually being called is:

Number.parseInt('10', 0) Number.parseInt('10', 1) Number.parseInt('10', 2)

discuss

order

iso8859-1|1 year ago

Typing fixes this, and anonymous records make it even better.

JavaScript lacks typing, and then they decided on a weird signature for the callback...

simon04|1 year ago

Unfortunately typing doesn't fix this. The 2nd callback function argument of Array.map is (index:number), and the 2nd argument of Number.parseInt is (radix:number).

It's a very nasty issue to debug.