#note_1: There are several ways I could have given the Mover class a move function. I could have done "this.move = function", but that would create a new function for each object. I could have created a global function with a name like "mover_move" and then set "this.move = mover_move", but that would clutter the list of global functions. Setting a function on the prototype seems to be the way I should be doing this.
You did the right thing here. This is the standard practice.
#note_2: I could call Mover.apply(arguments) here, but that would only take care of the x and y variables. The my_cat variable would not have a move() method.
#note_3: What am I supposed to be doing here? I feel like I should be doing some sort of complicated Cat.prototype = Mover.something.something.prototype.
The simplest way to make Cat inherit from Mover is to set Cat's prototype to a new instance of Mover.
[font=courier]Cat.prototype = new Mover();[/font]
You should still invoke [font=courier]Mover.apply(this, arguments)[/font] from the Cat constructor.
I'm also seeing a lot about Object.create(type, {many_braces: {value: magic_number}}) ...
Object.create is generally considered a cleaner way to set up inheritance than the example I showed above. The criticism of the above inheritance is that it unnecessarily invokes the Mover constructor. Object.create creates a new object that inherits from the passed object without invoking the constructor.
[font=courier]Cat.prototype = Object.create(Mover.prototype);[/font]
... but 1) that is messy as all hell ...
Regarding the second argument to Object.create, I don't think there's a consensus opinion among the JavaScript community, but I agree with you that the syntax seems unnecessarily verbose.
... 2) the value of many_braces cannot be changed from magic_number in the future ...
That's the default behavior, yes, but that behavior can be changed.
Cat.prototype = Object.create(Mover.prototype, {
many_braces: {
value: 'magic_number',
[b]writable: true,
enumerable: true,
configurable: true[/b]
}
});
... 3) this still doesn't solve the issue of having multiple constructors called.
Also true. You still have to do this manually with Mover.apply(this, arguments). There are several libraries that provide a custom mechanism for class definition and inheritance that fill missing features like this one, but if you're going to use just native JavaScript features, then this is what you're stuck with.