I'm fairly new to javascript, and I'm studying inheritance. I'm trying to understand the code below, but I don't quite get what lines 3 and 4 are all about. For one thing, why is the child's prototype property being set on line 2 the parent object, only to be set to something else on the following line. And I don't understand the arguments for the call() method. I thought the 1st arg was supposed to be the function context for Array.prototype.slice(). So why is 1 passed in? And the second arg seems to be the arguments object for Function.prototype.extend(). But I thought you needed to use apply() if the arguments to Array.prototype.slice() are in the form of an array. Anyway, I seem to be missing the whole point of this small block of code. Any insights by more experienced programmers would be much appreciated.
Thanks. Mike H
Code snippet comes from: http://www.htmlgoodies.com/html5/javascript/calling-parent-methods-in-javascript.html#fbid=D89pEqSy7xl
Function.prototype.extend = function(parent) {
var child = this;
child.prototype = parent;
child.prototype = new child(Array.prototype.slice.call(1,arguments));
child.prototype.constructor = child;
}