Assigning event handlers after the events may have

2019-05-26 06:31发布

问题:

Is this wrong?

var f = fs.createWriteStream('file');
otherStream.pipe(f);
f.on('finish', function() { /*...*/ })

Should it not be this:

var f = fs.createWriteStream('file');
f.on('finish', function() { /*...*/ })
otherStream.pipe(f);

?

Which one is better, and why?