I have to figure out, how to develop oop-javascript the right way. I read a lot about prototypes
but the internet explained to me, I need it only, if I create an object a lot of times. But my SuperInterface
exists only once. So I created it as an object:
var SuperInterface = {
superaction: function () {
alert(1);
},
actions: [{
title: 'This is great',
do_this: this.superaction
}],
init: function () {
console.log(this.actions[0].title);
this.actions[0].do_this();
}
};
SuperInterface.init();
Running init()
puts the title
successfully to the console. But the alert is never called. I do not understand, why not? What should I change?