Get the App
SLTechnology News&Howtos  ›  Development  › 

How es6 converts a number to a string

Shulou Source: shulou.com Published: 2022-05-31 20:28:52 09月28日 Update

Most people do not understand the knowledge points of this article "es6 how to turn numbers into strings", so the editor summarizes the following contents, detailed contents, clear steps, and certain reference value. I hope you can get something after reading this article. Let's take a look at this "es6 how to turn numbers into strings" article.

Conversion method: 1, use "+" to concatenate an empty character to the number, syntax "number +"; 2, use String (), you can convert the value of the object into a string, syntax "String (numeric object)"; 3, with toString (), you can return the string representation of the number, syntax "numeric .toString ()".

The operating environment of this tutorial: windows7 system, ECMAScript version 6, Dell G3 computer.

The method of converting a number into a string by es6

1. Concatenate a blank character to the number

Var a = 1 + "; alert (typeof a); / / string

2. Use the String method

The String () function converts the value of an object to a string.

Var a = 1scape console.log (typeof a); / / numbervar b = String (a); console.log (typeof b); / / string

3. Use the toString () method

The toString () method converts a number to a string and returns a string representation of the number.

Var a = 1scape console.log (typeof a); / / numbervar b = a.toString (); console.log (typeof b); / / string

The above is about the content of this article on "how es6 converts numbers into strings". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Tags: Numbers characters strings content methods objects grammars articles knowledge empty characters articles values functions most of them that is tutorials more steps environment computer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno Linux Apple Shulou Technology