我发现async有两个util函数:log
和dir
。
但我发现他们之间没有太多差异。见代码:
var async = require('async');
var x = function() {
this.name = 'Freewind';
}
var hello = function(name, callback) {
setTimeout(function() {
callback(null, 'hello ' + name, 'nice to see you ' + name, x, {a:'123'});
}, 200);
};
async.log(hello, 'world');
async.dir(hello, 'world');
打印:
hello world
nice to see you world
[Function]
{ a: '123' }
'hello world'
'nice to see you world'
[Function]
{ a: '123' }
您可以看到唯一的区别是后者在结果周围有更多'
。
是否有任何示例可以显示dir
可以执行哪些操作但log
无法执行此操作?
答案 0 :(得分:1)
在文档中说:
<强> async.log 强>
将异步功能的结果记录到控制台。一般来说,它使用console.log
<强> async.dir 强>
使用console.dir将异步函数的结果记录到控制台,以显示结果对象的属性。通常它使用console.dir。如果您使用FIrebug,它就像DOM选项卡中的视图。