Reputation: 4977
Is there any particular reason that this sort of construct would not work in JS? (JSLint does not accept it.)
(function(function(){
}){
})()
I can see this type of chaining going on forever, or at least as far as one would want/need.
Does anyone have any thoughts?
Upvotes: 0
Views: 280
Reputation: 140050
Did you mean:
(function () {
// ...
})((function () {
// ...
})());
Upvotes: 3
Reputation: 138072
You can create an anonymous function which accepts a function as an argument, and immediately pass it another anonymous function:
(function(fn) { })(function() { })
But I can't think of a single useful reason for doing that.
Upvotes: 0
Reputation: 124297
Well... yeah, it wouldn't work because it's not meaningful to embed an anonymous function in the argument list of an anonymous function. What are you trying to specify, there?
Upvotes: 0