The dd() method in collect.js is used to log the output of the function and stop the further execution thus exiting the current process.
Installation:
- Using NPM:
npm install collect.js
- Using CDN of collect.js
<script src="https://cdnjs.com/libraries/collect.js"></script>
Syntax:
collect.dd()
Parameters: It does not accept any parameters.
Return Value: It does not return anything.
Example 1:
Javascript
// Importing the collect.js module. const collect = require('collect.js');Â let array = [1, 2, 3, 4, 5, 6]; Â Â // Making the collection let collection = collect(array); Â Â // Using dd() function collection.dd(); |
Output:
Example 2: Code after dd() function will not be executed.
Javascript
// Importing the collect.js module. const collect = require('collect.js');Â let array = ["a", "b", "c"]; Â Â // Making the collection let collection = collect(array); console.log("Output is: "); Â Â // Using dd() function collection.dd(); Â Â // This will not be printed on the console console.log("neveropen for neveropen"); |
Output:
Reference: https://collect.js.org/api/dd.html

