8

Just a short reply to whoever deleted his rant because he didn't read the JS docs.

map is a map. You don't just dump a function call into there. You map the value to el and the value is then set to the function result.

This works:
new Array(38).fill("10").map(el => parseInt(el));

Comments
  • 3
    new Array(38).fill("10").map(parseInt(el)) ;
    This doesn't work.
  • 0
    .map(parseInt) should "work".
  • 2
  • 4
    map passes more than one parameter (eg index) to the enclosed function, so parseInt is getting a nonsense radix if the parameters aren't explicitly defined.
  • 1
    @platypus but it works

    Not the expected result, but it works.
  • 3
    @irene

    parseInt(str: string, radix: number = 10 or 6 or 8 depending on ie, but 10 got standardized);

    Array.prototype.map = <T, A extends T[]>(transformer: (value?: T, index?: number, array?: A) => any) =>
    return transformer(...arguments)

    Array is String, radix is number. It works. Programmers fault for incomplete knowledge. Simply the wrong syntax.

    I know the code is incomplete, can‘t bother cuz iPhone
Add Comment