Open In App

Collect.js dump() Method

Last Updated : 29 Jul, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

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


Next Article

Similar Reads