How to decouple methods from classes in JavaScript

Image for post
Image for post
Photo by David Rotimi on Unsplash

ery cool, thanks for sharing about how Object.assign() can be useful when working with objects in JavaScript Aphinya!!!

I thought the following example was very clear:

Image for post
Image for post

Keep up the great work writing about JavaScript Aphinya Dechalert!!!

Thanks to Christopher Jeffery for pointing out that Object.assign does not use prototypal inheritance; it instead applies the property/method directly to the instance of the object.

πŸ€“ The physical therapist who writes JavaScript πŸ’ͺ Web Developer 😎 Mentor 🧠 DPT πŸ˜„ SEO Expert 😁 React πŸ˜† Jamstack πŸ’¬ Ask me anything πŸ‘‰ DoctorDerek.com πŸ‘ˆ

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store