When map supplies more than one argument
Predict the line and identify which argument causes the surprise.
Code Snippet
const parts = ["11", "11", "11", "11"];
console.log(parts.map(parseInt).join(" "));
console.log(parts.map(part => parseInt(part, 10)).join(" "));Expected Output & Explanation
11 NaN 3 4
11 11 11 11 map passes (value, index, array). parseInt uses the index as its radix: 0 triggers radix inference, 1 is invalid, and the remaining values use base 2 and base 3.
Module Context & References
JavaScript · Language output drills Trace closures, receivers, prototypes, coercion and array edge cases
Personal Notes · Markdown