Returns a string representation of a number.
SyntaxtoString([ radix ])
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.
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.
15.7.4.2 Number.prototype.toString(radix)
ECMAScript® Language Specification Standard ECMA-262 5.1 Edition / June 2011
AttributionsMicrosoft Developer Network: Article
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