Augmented Types
Javascript and Ruby have many features in common, including the ability to add functionality to existing objects.
Ruby monkeypatching
Ruby allows you to reopen classes to add new functionality. For example, I can reopen the String class to add a new method, “foo()”:
1 2 3 4 5 6 7 8 9 10 |
|
Javascript augmenting
Javascript allows you to augment existing objects with additional functionality.
1 2 3 4 5 6 7 8 9 10 |
|