78
rated 0 times
[
84]
[
6]
/ answers: 1 / hits: 10264
/ 9 Years ago, mon, january 25, 2016, 12:00:00
I have a View
class that has a constructor method initialize
I think this is a constructor method, correct me if wrong.
var View = function(obj) {
this.initalize = obj.initalize;
};
What I would like to achieve is something gets called when the Class is instantiated.
How can I pass in an object like so?
var chatView = new View({
initialize: function() {
alert('Yay for initialization');
}
});
So that when I instantiate the View
I can pass an object to the constructor and within a key initialize
which value is a function and this key specifically gets called when instantiated.
More From » oop