It is recommended to have comments just before or immediately at the start of a function or class declaration/expression so that anyone who reads the code understands the purpose of the particular function or class.
function sum(a, b) {
return a + b;
}
/**
* Function to add two numbers
* @param a The first number to add
* @param b The second number to add
* @returns The sum of two numbers
*/
function sum(a, b) {
return a + b;
}