How to Print Function Signature in javascript

后端 未结 3 1988
再見小時候
再見小時候 2021-02-02 10:08

I have a function:

fs.readFile = function(filename, callback) {
    // implementation code.
};

Sometime later I want to see the signature of th

3条回答
  •  Happy的楠姐
    2021-02-02 10:38

    If what you mean by "function signature" is how many arguments it has defined, you can use:

    function fn (one) {}
    console.log(fn.length); // 1
    

    All functions get a length property automatically.

提交回复
热议问题