Javascript has prototype inheritance.
The code you pasted has a method called init declared as
klass.prototype.init = ...
Is like a public method of any copy of klass object.
In Javascript every object is linked to a special object named "prototype". Everything you put inside that special object will be accesible to new instances of the original object.
Example:
var Human = function(n){
this.name = n;
};
Human.prototype.getName = function(){
return this.name;
};
//instance of Human
var pedro = new Human("Pedro");
Now pedro has access to Human.prototype objects...
pedro.getName();
//return "Pedro"
pedro prototype "inherits" from Human.prototype, and Human.prototype "inherits" from Object.prototype.
Lets get back to your example:
Each copy of klass will be linked with klass prototype besides having its own prototype. So every copy of klass (in this case: every object returned by Class) will be able to use the functions defined in the original klass prototype.
klass is an object (functions are objects in js) encapsulated inside the definition of another object/function named Class.
Class generate instances of klass because that is what Class function return.
This code ilustrates a way of defining a pseudo class "Class", with a method called init, accesible from any object returned by the function Class
That way you could do:
var myClass = new Class(anArrayWithArguments);
In the context of the function klass: "this" inside Class means the klass object, and this can call init as well as myClass can do it like new instances returned by Class function.
init can.be considered like a constructor in your example.
apply called from init allow to invoke init with an array of arguments over the object this (the new object to be returned by Class)