I can't understand why the following code doesn't work.
var test=null;
(function(){
var Class=...
test=new Class();
})();
test.doSomething();// ERROR test is null
As I know if I don't declare variable using var than js must find the variable outside current scope (function). Please, say what I'm doin wrong.
EDIT
The full code:
var Application=null;
require(["Aqua","$"],function(Aqua,$){
var Class = Aqua.Application.extend();
Application = new Class();
});
Application.do("aaa");//Application is null
but the following works
var Application=null;
require(["Aqua","$"],function(Aqua,$){
var Class = Aqua.Application.extend();
Application = new Class();
Application.do("aaa");
});