Sarvesh Kesharwani Sarvesh Kesharwani - 1 year ago 89
Javascript Question

Does the @ symbol mean anything in javascript?

I noticed the @ symbols mentioned in many javascript files and couldn't figure out the significance of this character there. for example:

* Calls the specified callback function for all the elements in an array. The return value of
* the callback function is the accumulated result, and is provided as an argument in the next
* call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the
* callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start
* the accumulation. The first call to the callbackfn function provides this value as an argument
* instead of an array value.

So, does the @param mean anything here?

P.S. - The above is a description of a function with callbackfn and initialValue as parameters.

Answer Source

That comment is JSDoc. The @param callbackfn means "what follows is the description of the argument callbackfn".

Your IDE might be able to parse that format or you can use jsdoc to generate documentation from that.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download