A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/Number/toString below:

toString · WebPlatform Docs

toString Summary

Returns a string representation of a number.

Syntax
toString([ radix ])
radix
Optional. The base number system to convert to given as 2 - 36, inclusive. Defaults to 10.
Return Value

String representing the number value in the given base number system.

Negative numbers are simply preceded by the - sign, i.e. there is no conversion to a system like the Two’s Complement for binary.

Examples

The following example illustrates the use of the toString method with a number.

var mph_number = 234.567;
var mph_string = mph_number.toString();

console.log(mph_string);

console.log(mph_string.length);

The following example illustrates the use of the toString method with a radix argument.

var mph_number = 199;


mph_number.toString(16);



mph_number.toString(10);



mph_number.toString(8);



mph_number.toString(2);

implicit use of toString()

var mph_number = 199;
String(mph_number) === mph_number.toString(10);
(mph_number + "") === mph_number.toString(10);
Remarks Throws

RangeError when a radix outside the bounds of 2 - 36 (inclusive) was given.

See also Other articles External resources Specification

15.7.4.2 Number.prototype.toString(radix)

ECMAScript® Language Specification Standard ECMA-262 5.1 Edition / June 2011

Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4