Something like this? function person(name, address) { this.name = name; this.address = address; this.whoAmI = function() { if (this.creditLimit) alert(this.name + ' address:' + this.address + 'credit limit:' + this.creditLimit); else alert(this.name + ' address:' + this.address);
} return this; } function customer() { this.creditLimit = 0; this.creditCheck = creditCheck; return this; function creditCheck() { alert(this.creditLimit); } } var a = new person('john smith', '10 main st'); var cust = new customer(); a.whoAmI(); $.extend(a, cust); a.creditLimit = 1000; a.whoAmI(); On Jul 22, 10:02 pm, jeanluca <lca...@gmail.com> wrote: > Hi All > > I tried to add functions to an object like > > function User(n, a) { > this.name = n ; > this.aux = a ; > } > function auxis() { > alert(this.aux); > } > > $(document).ready( function() { > var u = new User("Jack") ; > u.extend({ > whoami: function() { alert(this.name); }, > autis: auxis > }) ; > u.whoami() ; > > }) ; > > Eventually I will have 2 object A and B and I want to merge A into B: > > B.exend(A) ; > > However it doesn't work at all. Any suggestions how to fix this ?