Javascript: How can I mix in methods of other Objects B, C to my Object A without copying but with linking?
问题 If I create an Object A: let A = {}; And want to mix in methods from other Objects B and C: let B = { foo() { alert("Boo!"); } }; let C = { bar() { alert("No!"); } }; Normally I would call: Object.assign(A, B, C); Then I change my function foo: Object.assign(B, { foo() { alert("Hooray!"); } }); Objcect.assign(C, { bar() { alert("Yes!"); } }); After that I call foo or bar: A.foo(); // Actual output: "Boo!", desired: "Hooray!" A.bar(); // Actual output: "No!", desired: "Yes!" So far I found out