Is it possible to make two or more JavaScript function objects that inherit properties from a common object?
var obj common = {
a: 'first',
b: 'second',
z: 'last'
};
var foo = function() {};
var bar = function() {};
// Some magic occurs here
foo.a; // 'first'
bar.z; // 'last'
One way to do this would be to employ a mixin, where we iterate through common and copy the properties over to foo and bar. However, if we have a huge list of properties, this could become inefficient.
Is there a more JavaScript way of doing this? I would love to use the prototype chain here, but I don't know if it's possible.