Name

toString() — NN 3 IE J3 ECMA n/a

Synopsis

toString(radix)

Returns a string version of a number in the number base specified by the radix parameter. This variant of the toString() function lets you perform number base conversions. For example, the following sequence converts a base-10 number to a base-16 version as a string:

var a = 32
var b = a.toString(16)

After these statements execute, the value of b is "20".

Returned Value

A string.

Parameters

radix

An integer of the number base of the result (e.g., 2, 10, 16).

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.