(function(test){console.log(test)})(1)<p>I don't think this really exists in other languages outside of JS. Where you can send in a parameter this way. I understand that the test variable becomes what ever you pass in the tail end but how does this work? What is this called so I can better ask other JS developers?
Immediately Invoked Function Expressions (IIFE).<p><a href="http://benalman.com/news/2010/11/immediately-invoked-function-expression/" rel="nofollow">http://benalman.com/news/2010/11/immediately-invoked-functio...</a><p>Not unique to js, e.g. upcoming php v7 will support these.
What you have is a self executing anonymous function. Now you know the name you will be able to find out all the information you need. For example: <a href="http://esbueno.noahstokes.com/post/77292606977/self-executing-anonymous-functions-or-how-to-write" rel="nofollow">http://esbueno.noahstokes.com/post/77292606977/self-executin...</a>
This is the same as:<p><pre><code> var func = (function(test){console.log(test)});
func(1);
</code></pre>
What's going on is you're creating an anonymous function, and then calling it.
So after looking at this longer, it makes a lot more sense. Basically, things are evaluated left to right. The first (function(){}) evaluates the function(){} and returns the function. Then the function is called with the second (1), and passing that in as a param.