Monday, March 26, 2018

Anonymous f

Sometimes, there is a function called that has no name. It is known
as an anonymous function. An example, below. Notice that the function executes
directly, there is an ; after the () . The second example names the function, and passes
it as a parameter to setInterval. There is no ; at the end, but a coma. It is a named
function. It too will execute but - contrary to the original - only once. In effect, we
have left the loop created by setInterval().

Indeed, the script in the head defines it as a function with function  fGreeting().

The third example stays ion the loop. One can see in the last how the modulo operator captures by how much the width has grown...




                                                     *     *     *



No comments: