Collect.js dump() Method

The dump() method in collect.js is used to print the data at particular moment and then continue further executing the code.
Syntax:
collect.dump()
Parameters: It does not accept any parameters.
Return Value: It does not return any value.
Example 1:
Javascript
// Importing the collect.js module const collect = require('collect.js'); let array = ["a", "b", "c"]; // Making the collection let collection= collect(array); // Using dump() method to print // the data at this moment collection.dump() |
Output:
Collection { items: [ 'a', 'b', 'c' ] }
Example 2:
Javascript
// Importing the collect.js module. const collect = require('collect.js'); let array = ["a", "b", "c", "d", "e"]; // Making the collection let collection = collect(array); // Using dump() method to print // the data at this moment collection.dump() .filter((v, k) => v >= "c") .dump() |
Output:
Collection { items: [ 'a', 'b', 'c', 'd', 'e' ] }
Collection { items: [ 'c', 'd', 'e' ] }
Reference: https://collect.js.org/api/dump.html
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek 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!



