Underscore.JS - noop 方法

语法

_.noop()

无论传递什么参数,noop 方法都会返回未定义。它对于默认可选回调参数很有用。请参阅以下示例 −

示例

var _ = require('underscore');

//示例 1:检查 noop 是否返回未定义
console.log(undefined === _.noop());

将上述程序保存在tester.js中。运行以下命令执行该程序。

命令

\>node tester.js

输出

true

underscorejs_utilities.html