Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript String() Function

JavaScript String() Function

Function Reference JavaScript Global Functions


Definition and Usage

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

Syntax

String(object)

Parameters Description
object Required. A JavaScript object.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the String() function.


Tips and Notes

Note: The String() function returns the same value as the toString() method of a string object.


Example

Example

Convert different objects to strings:

The output of the above example is:

Try it »


Function Reference JavaScript Global Functions