Open In App

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:




// 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:




// 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

Article Tags :