JavaScript String()
Examples
Convert different values to strings:
String(new Date());
String("12345");
String(12345);
Try it Yourself »
Description
The String()
method converts a value to a string.
Note
The String() method returns the same as the toString() method for any value.
Syntax
String(value)
Parameters
Parameter | Description |
value | Required. A JavaScript value. |
Return Value
Type | Description |
A string. | The value converted to a string. |
Browser Support
String()
is an ECMAScript1 (JavaScriopt 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
More Examples
Examples
Convert different values to strings:
String(Boolean(0));
String(Boolean(1));
String([1,2,3,4]);
Try it Yourself »