toString

Modified on Wed, 02 Aug 2023

Description

Convert `value` to a string. An empty string is returned for `null` and `undefined` values. The sign of `-0` is preserved.

Syntax

toString(value)

Parameters

Input ParameterTypeDescription
valueanyThe value to convert.

Return value

Type
string

Sample

ExampleResultDescription
toString(22)'22'Number to string
toString(-0)'-0'Negative number to string
toString(-1.23)'-1.23'Negative number to string
toString([1, 2, 3])'1,2,3'List to string
toString(null)''Convert null value empty string

To view all the String functions, click here.

See Also