Collect.js dd() 方法
collect.js 中的dd() 方法用于记录函数的输出并停止进一步执行从而退出当前进程。
安装:
- 使用 NPM:
npm install collect.js
- 使用 collect.js 的 CDN
句法:
collect.dd()
参数:它不接受任何参数。
返回值:它不返回任何东西。
示例 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();
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("geeks for geeks");
输出:
示例 2: dd()函数之后的代码不会被执行。
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("geeks for geeks");
输出:
参考: https://collect.js.org/api/dd.html