Member Injection: Instance

Learn how to inject a member into an instance in JavaScript.

Querying an object to find out what it contains is like asking a restaurant what’s on their menu. The kind of restaurants we like to frequent best are the ones willing to make what we like, off the menu, within reason, of course. In other words, you may want to make up stuff in a class that’s not already there. Enter member injection.

📍 You can use member injection to introduce brand-new methods into an object or into the prototype of a class.

Get hands-on with 1200+ tech skills courses.