Collect.js unwrap() Method Last Updated : 03 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The unwrap() method is used to unwrap the given collection. Syntax: collect(array).unwrap() Parameters: The collect() method takes one argument that is converted into the collection and then unwrap() method is applied on it. Return Value: This method returns a array or object. Below example illustrate the unwrap() method in collect.js: Example 1: JavaScript const collect = require('collect.js'); let arr = ['C++', 'java', 'python']; const collection = collect(arr); let newObject = collect().unwrap(collection); console.log(newObject); Output: ["C++", "java", "python"] Example 2: JavaScript const collect = require('collect.js'); let arr = [1, 2, 3, 4, 5]; const collection = collect(arr); let newObject = collect().unwrap(collection); console.log(newObject); Output: [1, 2, 3, 4, 5] Comment More infoAdvertise with us Next Article Collect.js pop() Method C code_hunt Follow Improve Article Tags : JavaScript Web Technologies Collect.js Similar Reads Collect.js union() Method The union() method is used to add the given array to the collection with the unique values. If the given array contains values that are already in the original collection, the original collection's values will be preferred. Syntax: collect.union() Parameters: The collect() method takes one argument 1 min read Collect.js pad() Method The pad() method is used to fill the array with the given element until the size of the array is full. We use a negative size to pad the elements left side and use a positive sign to pad elements right side. If the array size is full then no padding will perform. Syntax: collect(array).pad(size, val 2 min read Collect.js sum() Method The sum() method in collect.js is used to return the sum of all the items in the given collection. Syntax: collect(array).sum() Parameters: The collect() method takes one argument that is converted into the collection and then sum() method is applied on it. Return Value: This method returns the sum 1 min read Collect.js pop() Method The pop() method is used to remove the last element from collection and returns the popped element. Syntax: collect(array).pop() Parameters: The collect() method takes one argument that is converted into the collection and then pop() method is applied on it. Return Value: This method returns the pop 1 min read Collect.js put() Method The put() method is used to set the given key and value in the collection. Syntax: collect(array).put(key) Parameters: The collect() method takes one argument that is converted into the collection and then put() method is applied on it. The put() method holds the key as parameter. Below example illu 1 min read Collect.js nth() Method The nth() method is used to create a new collection consisting of every n-th element. Syntax: collect(array).nth(num) Parameters: The collect() method takes one argument that is converted into the collection and then nth() method is applied on it. The nth() method holds a number. Return Value: This 1 min read Like