News for hackers. Stuff that matters.
Re:Refactoring Legacy JavaScript Code to Use Classes by tchaffee on Wednesday March 08, 2017 @01:00AM (#13818287)
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

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 Either you're doing composition wrong, or I'm not doing inheritance like you are claiming.

There are no comments on this comment yet.