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
const collect = require( 'collect.js' );
let array = [ "a" , "b" , "c" ];
let collection= collect(array);
collection.dump()
|
Output:
Collection { items: [ 'a', 'b', 'c' ] }
Example 2:
Javascript
const collect = require( 'collect.js' );
let array = [ "a" , "b" , "c" , "d" , "e" ];
let collection = collect(array);
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
Share your thoughts in the comments
Please Login to comment...