-
Notifications
You must be signed in to change notification settings - Fork 177
Closed
Description
Browsing the recipes, I found one pattern to be quite common: The extension of build-in native objects.
It's totally fine to back-port ECMAScript 5 methods (as long you make sure, you don't overwrite existing implementations by accident), e.g.:
unless String::trim then String::trim = -> @replace /^\s+|\s+$/g, ""
On the other hand, modifying objects you don't own is considered a bad practice in JavaScript (whereas it's quite common in other languages like Ruby):
- Maintainable JavaScript: Don’t modify objects you don’t own by Nicholas C. Zakas
- Extending built-in native objects. Evil or not?
Personally, I think those examples should either be reworked or have a note in the "Discussion" section, that this should be used with caution, linking the articles above.
What do you think?
Metadata
Metadata
Assignees
Labels
No labels