JavaScript conversion between numeric and string types_javascript skills
- WBOYOriginal
- 2016-05-16 18:49:221207browse
1. Conversion from numeric type to String type
Assume that the numeric type (int/float/double) variable is: num and the string obtained after conversion is: str
Then it is converted to There are three ways to use strings, as follows:
(1) str = String.valueOf(num);
(2) str =Integer.toString(num);
(3) str =num "";
2. Conversion from String type to numeric type (take int as an example here, double and float are similar)
There are two conversion methods, as follows:
( 1) num=Integer.parseInt(str);
(2) num=Integer.valueOf(str).intValue();
This part is relatively easy to implement, so no examples will be given here.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn