I’m struggling a bit with JavaScript. I only get the folling code working if i call the init function inside another function. If i call this.init() or that.init() outside the timeout-function, it doesn’t work.
var App = function() {
var that = this;
// Workaround
var timeout = setTimeout(function(){
that.init();
},1);
};
var app = new App();
App.prototype.init = function() {
console.log('works');
};
Thanks you for your help.
Cheers.
You’re assigning the prototype after you instantiate App. Do it before.