javascript join() method


  Translation results:

UK[dʒɔɪn] US[dʒɔɪn]

vt.& vi.Join; participate; connect; connect

vt.Participate; combine; get on (train, plane, etc.); get on (Road)

n. connection; combination; joint; joint point

Third person singular: joins Present participle: joining Past tense: joined Past participle: joined

javascript join() methodsyntax

How to use join() method?

The join() method in JavaScript can be used to put all elements in an array separated by the specified delimiter into a string.

Function: Used to put all the elements in the array into a string. Elements are separated by the specified delimiter.

Syntax: arrayObject.join(separator)

Parameters: separator Optional. Specify the delimiter to use. If this parameter is omitted, a comma is used as the delimiter.​

Return: Returns a string. The string is generated by converting each element of the arrayObject to a string and then concatenating the strings, inserting the separator string between the two elements.

javascript join() methodexample

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">

    var arr = new Array(3)
    arr[0] = "George"
    arr[1] = "John"
    arr[2] = "Thomas"

    document.write(arr.join())

</script>
</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A