I am looking at this tutorial. I know that it is using an anonymous function, from this answer: Why do you need to invoke an anonymous function on the same line?
I understand that the () at the end of the function will autoexecute the prior function -- passing (this) as the parameter. I understand that the (this) in the function refers to the global this.
I understand that people use this anonymous function pattern to protect against pollution in the global namespace.
However, I do not understand how you would USE the cow defined in the anonymous function. For instance, in python, if you imported a class cow from cow import cow
, you could do Cow(name)
. Or in java you could do new Cow (name)
If you define a cow in an anonymous function (to protect the global namespace) -- how do you use it?