Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
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.
-
@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
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));
random