VOOZH about

URL: https://www.geeksforgeeks.org/javascript/collect-js-concat-method/

⇱ Collect.js concat() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collect.js concat() Method

Last Updated : 4 Jan, 2022

The concat() method is used to return the merged arrays or objects represented by the collection. The JavaScript array is first transformed into a collection and then the function is applied to the collection.

Syntax:

collect(array1).concat(array2)

Parameters: The collect() method takes one argument that is converted into the collection and then concat() function also take an array.

Return Value: Returns a merged array or object.

Below examples illustrate the concat() method in Collect.js:

Example 1: Here collect = require('collect.js') is used to import the collect.js library into the file.

Output:

Result : [ 1, 2, 3, 'a', 'b', 'c' ]

Example 2:

Output:

Result : [ 1, 2, 3, 'a', 'b', 'c', 'GeeksforGeeks', 'Collect.js' ]

Reference: https://collect.js.org/api/concat.html

Comment
Article Tags: