3 ms·
> 'foo'.padStart(20) < " foo" The fact that Array.prototype.map has different semantics from Python's map built-in, as most likely encounte
by spiralx 8y ago
> 'foo'.padStart(20)
< " foo"
The fact that Array.prototype.map has different semantics from Python's map built-in, as most likely encountered by newcomers to JavaScript with the [...].map(parseInt) issue, is something that bit me once, maybe twice, before I adjusted to it - especially given that I'm more likely to use comprehensions than map in Python nowadays anyway. And the fact that the callback receives the index in JS is useful in far more situations than it causes problems, and it's certainly nicer than
>>> [ callback(v, i) for (i, v) in enumerate(arr) ]
when you want the index position.