If I remember my Javascript correctly, the reason it works in Global is because in your self-executing example, the variable FOO_BAR_ANON is outside the scope of Foo. When I included my JS validator in Eclipse RSA, your line
this.fooBar = FOO_BAR_GLOBAL;
cannot resolve the value, because with respect to foo the variable does not exist within its scope.
Also, to suppress this, my options for Javascript were as follows: Project-> Properties-> JavaScript-> Validation-> Errors and Warnings.
Here you can configure which alerts are issued or ignored. Your version of Eclipse may be different.
source share