If you don't mind setting the function on instances at construct time, you can use ES2016 class properties:
class x {
a = wrapFunction(function() {})
}
This kind of use case is pretty well covered by ES2016 decorators as well (they're a bit more general as they act on property descriptors, not just values):
Neat, thanks! But we're working with the half-baked V8 ES6 support that is far from ES2016, unfortunately. However, it's interesting to see the support coming :-)
However, I doubt that I would use it - most of the 'modernizations' are really dependent on the context of each change and require some tweaking.
For instance, ES6 classes do not allow for inline computed methods:
--- this is impossible: --- So we're still required to use the explicit prototype way of declaring the class.Then you can't just rewrite all methods to arrow functions because they don't have prototypes, even when they're really tempting:
---> ...$0.02