Skip to Main Content
Rediscovering JavaScript
book

Rediscovering JavaScript

by Venkat Subramaniam
June 2018
Beginner content levelBeginner
288 pages
6h 31m
English
Pragmatic Bookshelf
Content preview from Rediscovering JavaScript

Member Injection

Querying an object to find out what it contains is like asking a restaurant what’s on their menu. The best kind of restaurants I like to frequent are the ones willing to make what I 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. The member you add to an object is then available for use on that particular object. The member you inject into a prototype of a class becomes available on all the instances of that class.

Use member injection to add convenience methods or properties that you feel should be in a class. These ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Object-Oriented JavaScript - Third Edition

Object-Oriented JavaScript - Third Edition

Stoyan STEFANOV, Ved Antani
Deno Web Development

Deno Web Development

Alexandre Portela dos Santos

Publisher Resources

ISBN: 9781680506174Errata Page