I'm trying to inherit the methods of one object into another.
I've got the base object , which is implemented using the Revealing Module Pattern.
Page = function(url) {
...
return { something: something_I_defined_above }
...
}
The other object where Page should inherit from is defined as a singleton. In the actual file Page is defined before Link is.
Link = function() {
this.add = function() {}
var instance = this;
Link = function() { return instance; }
}
Next I want Page to inherit from Link.
Page.prototype = new Link();
When testing this code I get undefined for the p function:
var p = new Page();
// The following line return undefined.
p.add;