Open In App

Collect.js dump() Method

Improve
Improve
Like Article
Like
Save
Share
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


Last Updated : 29 Jul, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads