I am aware of functions being declared and immediately called, like so
(function(arg) {...}(value))();
but what does this mean:
functionName(function(params){...});
It is in the (first non code line of the) demo/demo.js file of the Ace editor and it is the worst javascript code I have yet encountered. I want to know if it is really poorly written or if I am too novice to decipher it.
In this case,
contains the definition of their module in an anonymous function, which
outerFuncuses to control how it’s defined. In the code you’re referring to they use thedefinefunction from RequireJS to do several things, including specifying dependencies and executing context.define()is part of the CommonJS modules specification, and needs to be implemented differently on different JavaScript platforms you’re using. This code design is more than reasonable; it’s following the proposed specifications that may be a core part of the language in the future.