JavaScript gotchas

1 · JonLuca De Caro · July 18, 2021, 6:25 p.m.
Here are some interesting JavaScript facts that I’ve encountered over the last few years. Function.length Call Function.length will return the number of arguments a function is expecting. The spread operator will not be included in the count. Array.map(func) when you call Array.map(func), the mapped function gets called with 3 arguments, not just the value. So for: ['10', '11', '12'].map(parseInt); You’d expect to get [10, 11, 12] but in reality get [10, NaN, 1] This is because .map...