I'm a bit new to Object Inheritance in JavaScript and I'd like to find
the best way to do so. I have seen a few techniques from Resig to
Crockford, but I'd like to know the simplest and most effective way to
create object from existing ones. Is there any native way that this
can be done elegantly? Am I going to have to create a function to
create my objects using something like Crockford's beget method?
For example, I'm using Raphael.js to construct a circle Object that
I'd like other Objects to inherit from:
var Circle = function(){
return {
type: "circle",
x: 0,
y: 0,
cx: 31,
cy: 32,
r: 1,
fill: "#00AEEF"
}
}
To get a new instance of it, I'm using this:
var inner = new Circle;
inner.r = 20; //modify r for 'inner' object
Is there a more efficient way of doing this?
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]