Home>Article>Web Front-end> How to convert numbers to characters in javascript

How to convert numbers to characters in javascript

青灯夜游
青灯夜游 Original
2021-10-18 17:45:01 6303browse

Conversion method: 1. Use the String() function, the syntax "String(numbe)", to convert the parameter value into a string; 2. Use the toString() method, the syntax "number.toString()" ;3. Use " " operator, syntax "number ''".

How to convert numbers to characters in javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Method 1: Use the String() function

String(value): Force the parameter value to a string.

String(0); //返回字符串"0" String(1); //返回字符串"1"

How to convert numbers to characters in javascript

Method 2: Use toString() method

var number = 5; number.toString();

How to convert numbers to characters in javascript

method 3: Use the " " operator

and add an empty string

var number = 5; number + '';

How to convert numbers to characters in javascript

##[Recommended learning:

javascript advanced tutorial

The above is the detailed content of How to convert numbers to characters in javascript. For more information, please follow other related articles on the PHP Chinese website!

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