anonymous functions with JavaScript?

are anonymous functions allowed in Unity? if not, why not?

is just tried to run the following simple script:

(function() { Debug.Log("blub"); })();

No, anonymous functions or closures does not work in in Unity Javascript. It is not really javascript, but rather a close syntactic cousin. It compiles down to CLR 2.0, which comes from a time before the DLR and with limited dynamic typing support. Duck-typing and the object <=> dict equivalence found in javascript is not supported either. All in all, I'd say it is probably closer to C# 2.0 than javascript.

This question and some of the comments therein are slightly related: http://answers.unity3d.com/questions/44/is-there-a-performance-difference-between-unitys-javascript-and-c

Anonymous functions are allowed in Javascript with Unity 3.0.