JavaScript String() Method | JS to string
ExamplesConvertdifferentvaluestostrings:String(newDate());String("12345");String(12345);TryitYourself»[1]DefinitionandUsageTheString()methodconvertsavaluetoastring.NoteTheString()methodreturnsthesameasthetoString()methodforanyvalue.SyntaxParametersParameterDescriptionvalueRequired.AJavaScriptvalue.ReturnValueTypeDescriptionAstring.Thevalueconvertedtoastring.BrowserSupportString()isanECMAScript1(ES1)feature.ES1(JavaScript1997)isfullysupportedinallbrowsers:ChromeEdgeFirefoxSafariOperaIEYesYesY...
ExamplesConvert different values to strings:
String(new Date());String("12345");String(12345);
Try it Yourself »[1] Definition and UsageThe String() method converts a value to a string.
NoteThe String() method returns the same as the toString() method for any value.
Syntax Parameters Parameter Description value Required.A JavaScript value. Return Value Type Description A string.The value converted to a string. Browser SupportString() is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome Edge Firefox Safari Opera IE Yes Yes Yes Yes Yes Yes More Examples ExamplesConvert different values to strings:
String(Boolean(0));String(Boolean(1));String([1,2,3,4]);
Try it Yourself »[2] References Try it Yourself » (www.w3schools.com) Try it Yourself » (www.w3schools.com)