What's the second set of parentheses mean after a require statement in Node.js?

前端 未结 2 1211
心在旅途
心在旅途 2020-12-18 04:55

I\'m working with a coworkers code today and I saw something I\'ve never seen before.

I understand the first part of the statement (require in the file clean.js).

2条回答
  •  遥遥无期
    2020-12-18 05:43

    Whatever is exported from ./tasks/clean is a function, so it's just being invoked with 'js' and './dist/js' as parameters

    It is equivalent to the following:

    const clean = require('./tasks/clean');
    clean('js', './dist/js');
    

提交回复
热议问题