JavaScript Array join() Method | js join
ExampleConverttheelementsofanarrayintoastring:constfruits=["Banana","Orange","Apple","Mango"];fruits.join() //Returns"Banana,Orange,Apple,Mango"TryitYourself»[1]More"TryitYourself"examplesbelow.DefinitionandUsageThejoin()methodreturnsanarrayasastring.Theelementswillbeseparatedbyaspecifiedseparator.Thedefaultseparatoriscomma(,).join()doesnotchangetheoriginalarray.BrowserSupportjoin()isfullysupportedinallbrowsers:ChromeIEEdgeFirefoxSafariOperaYesYesYesYesYesYesSyntaxParameterValuesParameterD...
ExampleConvert the elements of an array into a string:
const fruits = ["Banana", "Orange", "Apple", "Mango"];fruits.join() // Returns "Banana,Orange,Apple,Mango"
Try it Yourself »[1]More "Try it Yourself" examples below.
Definition and UsageThe join() method returns an array as a string.
The elements will be separated by a specified separator. The default separator is comma (,).
join() does not change the original array.
Browser Supportjoin() is fully supported in all browsers:
Chrome IE Edge Firefox Safari Opera Yes Yes Yes Yes Yes Yes Syntax Parameter Values Parameter Description separator Optional. The separator to be used. If omitted, the elements are separated with a comma Technical Details Return Value: A String, representing the array values, separated by the specified separator JavaScript Version: ECMAScr...