Please, can someone tell me what does this.init.apply(this, arguments)
do in the code below?
I understand what apply()
does in general, but in the context of the code below, what is it doing in there?
var Class = function() {
var klass = function() {
this.init.apply(this, arguments); //I don't really get this bit...
};
klass.prototype.init = function(){};
return klass;
};
var Person = new Class;
//Usage
var someone = new Person;
I see a lot of people using it. I've got an idea of what it does but can't really put my hands on it so I need more light.
I'm going up an extra level in JS, so I wanna know everything about it, not just the simple 'Hello world' level.
Many thanks