When I want to know the number of arguments and argument types of a function in python, i just use the function help() to get them. But in javascript or nodejs, it is really hard to know the argument type and number of arguments of a function. Is there any function similar to Python's help in Javascript or is there any other way to get that information?
JavaScript is dynamically typed, so it is hard to tell the types. For the number of arguments, you can try Function.length
with some caveats. Some hints about argument type of not built-in functions can provide Function.prototype.toString()
, with full or truncated output. For example:
> fs.read.length
6
> fs.read.toString().replace(/\{.+/s, '')
'function read(fd, buffer, offset, length, position, callback) '
Or you can use TypeScript with IDE)