Home > Web Front-end > JS Tutorial > body text

JavaScript conversion between numeric and string types_javascript skills

WBOY
Release: 2016-05-16 18:49:22
Original
1203 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:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!