How do you register anonymous functions?

I specifically refer to the anonymous JavaScript function, but this may be relevant to other languages. I like to use JSDoc notations in my scripts because I know that other people will hack it sooner or later. When I have a rather complicated anonymous function, how do people document it so that it is compiled by Eclipse and other IDEs that understand JSDoc or JavaDoc notations?

/**
 * Blah Blah blah
 *
 * @param Object Blah blah blah
 * @return Blah Blah Blah
 * @type Object
 */
function foo(this) {
......
this.bar = function () { ... complex code .....};
......
return obj;
}

thank

+3
source share
3 answers

Ideally, an anonymous function should be short and perform a direct task. So ... the external function that contains it should provide sufficient documentation.

, , , , .

+10

. . "bar", , , "foo.bar". , , , . , - , , :

var intervalId = setTimeout(function() { // statements }, 1000);

, Javascript: The Definitive Guide, - " Function()". , , "" .

? , -, . , "" Javascript , , -.

+1

Not anonymously.

I believe the best way to document something is wrong. I mean, I use good variable / function names and clean code as my document.

So, in this case, I would just create a static function that creates this anonymous, and so I can give this static function a good name .it

0
source

Source: https://habr.com/ru/post/1740018/


All Articles