I probably thought, but I have problems processing Nodejs documentation. I am new to javascript and come from a Java background.
My question is not about any particular nodejs function, but just about a common understanding. Below I will give an example of what I'm trying to understand ...
When working with a statically typed language like Java, it is very clear which types are needed for method calls. A trivial example, if I want to sort an int array, I can just look at Arrays.sort and see that it needs int [] (the same for other types). I also see that it returns void.
public static void sort(int[] a)
However, javascript is a dynamic language, so there are no types for api calls. Take this example in a crypto module
crypto.pbkdf2(password, salt, iterations, keylen, callback) Asynchronous PBKDF2 applies pseudorandom function HMAC-SHA1 to derive a key of given length from the given password, salt and iterations. The callback gets two arguments (err, derivedKey).
So, without going out and finding an example of the code, or looking at the source of nodejs, how to find out the types of function arguments? I realized that you can get types by looking at the name (i.e. the callback is the type of the function), but is there any other way?
For example, the documentation says that the callback receives two arguments err and a derivativeKey. What is the type of derivative key, what type or error? Am I missing something in the documentation? How do you know if you walk in the right types?
Note. I already know what the type of the derivedKey and err is, so I don't need answers like "generateKey is ....". My question is a general understanding of Nodejs documentation for someone coming from a statically typed language and not relevant to crypto.pdkdf2.