Skip to content

Comment on Show HN: ES7 Decorator library adds types checking, memoization, and more to JSparent

Comments

The main other benefit of decorators is that they work on property descriptors, and are automatically passed property names and the target object, so you have a bit more info.

Having the descriptor means for instance that you can switch a value to use a getter function, and that enables a bunch of interesting functionality that you couldn't otherwise do.

One example that I like is automatically binding methods to the current instance on first property access.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.