Friday, September 19, 2025
HomeLanguagesJavascriptCollect.js join() Method

Collect.js join() Method

The join() method is used to join the collection elements with given string and returns the collection elements.

Syntax:

collect(array).join()

Parameters: The collect() method takes one argument that is converted into the collection and then join() method is applied on it.

Return Value: This method joins the collection elements with given string and returns the values.

Below example illustrate the join() method in collect.js:

Example 1:




const collect = require('collect.js');
  
let arr1 = [10, 20, 30, 40, 50];
  
const collection1 = collect(arr1);
  
console.log(collection1.join(', '));
  
let arr2 = ['a', 'b', 'c', 'd'];
  
const collection2 = collect(arr2);
  
console.log(collection2.join(', ', ' and '));


Output:

10, 20, 30, 40, 50
a, b, c and d

Example 2:




const collect = require('collect.js');
  
let arr = ['Geeks', 'GFG', 'neveropen'];
  
const collection = collect(arr);
  
console.log(collection.join(', '));


Output:

Geeks, GFG, neveropen
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32301 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6666 POSTS0 COMMENTS
Nicole Veronica
11840 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11898 POSTS0 COMMENTS
Shaida Kate Naidoo
6781 POSTS0 COMMENTS
Ted Musemwa
7056 POSTS0 COMMENTS
Thapelo Manthata
6739 POSTS0 COMMENTS
Umr Jansen
6744 POSTS0 COMMENTS