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:
Example 1:
javascript
function joinDemo() { const str = arr.join( "*" ); console.log(str); } const arr = [17, 55, 87, 49, 78]; joinDemo(); |
Output:
17*55*87*49*78
Example 2:
javascript
function joinDemo() { const str = arr.join( "" ); const str1 = arr.join( "$" ); console.log(str); console.log(str1); } const arr = [ 'C' , 'Java' , 'Python' ]; joinDemo(); |
Output:
CJavaPython C$Java$Python
Please Login to comment...