Logo

Programming-Idioms

History of Idiom 22 > diff from v61 to v62

Edit summary for version 62 by programming-idioms.org:
Admin deletes impl 356

Version 61

2016-11-30, 20:49:25

Version 62

2017-02-02, 21:01:40

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Illustration
Extra Keywords
int base conversion
Extra Keywords
int base conversion
Code
i = 0+str;
Comments bubble
JavaScript automatically converts a string to a number when you use it in a numeric expression.
(This also works with floating point numbers.)