How can I set and access a global var in a prototype way?
var app;
(function(){
"use strict";
var App = function() {
};
App = App;
}(window));
$(function() {
app = new App();
});
How can I set and access a global var in a prototype way?
var app;
(function(){
"use strict";
var App = function() {
};
App = App;
}(window));
$(function() {
app = new App();
});
When you're using strict mode, the value of this inside the IIFE isn't window, it's probably undefined, so App isn't really global.
If you explicitly make it global it should work
var app;
(function (w) {
"use strict";
w.App = function () {
};
}(window));
$(function () {
app = new App();
});
If you weren't using strict mode, you could just remove the var keyword