In JavaScript, if I initialize an object like so:
var foo = {};
is there a way to get the prototype of that object? The prototype quite well may be undefined. But actually, what I really want is just the defined fields and functions/methods that foo may have:
var foo = {
field1: '',
method1: function(){}
};
I am trying to create a classical inheritance system, but Object.create() seems to want arguments that represent prototypes and nothing else.
In other words, I want var bar = {}
to inherit from foo. But both bar and foo are objects initialized with {}
.
How can I add the methods from one object to another with or without dealing with prototypes?