Y
Hacker News
new
|
ask
|
show
|
jobs
by
bemmu
2561 days ago
If you want to get terse
['1', '7', '11'].map(x => +x)
2 comments
plausibilities
2561 days ago
If I didn't care about rounding I'd just use a primitive constructor
['1', '7', '11'].map(Number)
link
jacobolus
2561 days ago
This coerces to a number, but not to an integer.
link
reaktivo
2561 days ago
I would hate to see it in code that is being shared in a team, but the following works:
['1', '7', '11'].map(x => ~~x)
link