4 ms·
I can get foo.author.title and foo.post.title no problem using Object.assign: Object.assign({}, { author: author }, { post: post }); Can you give a better e
by tchaffee 10y ago
I can get foo.author.title and foo.post.title no problem using Object.assign:
Object.assign({}, { author: author }, { post: post });
Can you give a better example of where a reference to an instance is any different than copying an instance?
EDIT: I fixed your example. https://jsbin.com/zamuqoropa/1/edit?js,console https://jsbin.com/zamuqoropa/1/edit?js,console
EDIT 2: In fact, my Object.assign does exactly the same thing as your example of composition. And
console.log(obj1.author === obj2.author);
produces 'true'.
https://jsbin.com/vafudizumo/1/edit?js,console https://jsbin.com/vafudizumo/1/edit?js,console
Either you're doing composition wrong, or I'm not doing inheritance like you are claiming.