Node.js | join() function

join() is an array function from Node.js that is used to return a string from the array.

Syntax:

array_name.join(parameter)

Parameter: This function takes a single parameter as per which the join operation has to be performed.



Return type: The function returns the string.

The program below demonstrates the working of the function:
Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

function joinDemo()
{
  var str= arr.join("*");
  console.log(str);
}
var arr=[17, 55, 87, 49, 78];
joinDemo();

chevron_right


Output:

17*55*87*49*78

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

function joinDemo()
{
  var str= arr.join("");
  var str1= arr.join("$");
  console.log(str);
  console.log(str1);  
}
var arr=['C','Java','Python'];
joinDemo();

chevron_right


Output:

CJavaPython
C$Java$Python


My Personal Notes arrow_drop_up

Contented with little yet wishing for more

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.