Home > Web Front-end > JS Tutorial > JavaScript conversion between numeric and string types_javascript skills

JavaScript conversion between numeric and string types_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:49:22
Original
1262 people have browsed it
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.
Related labels:
Statement of this Website
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
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template