DEV Community

Discussion on: Re-implementing jQuery methods in the HTMLElement prototype

Collapse
 
krofdrakula profile image
Klemen Slavič

Nice write-up of extending the base prototypes!

I do have a bit of a hang-up with modifying prototypes of builtins without using Object.defineProperty, though. If any application is inspecting the prototype, those properties are enumerated, so it might be better to define them as non-enumerable on the prototype object, just to be on the safe side. A factory function that would augment a built in by taking a property name and a function would make the examples just as readable. :)

I love articles like this that make it clear just how thin an abstraction layer you can have on top of the standard web API.

Collapse
 
somedood profile image
Basti Ortiz

It also gives you an idea on what Babel does under the hood.