DEV Community

Discussion on: From classes to plain objects and pure functions

Collapse
 
pociej profile image
Grzegorz Pociejewski

Hmm to be honest i dont understand step 4, to get rid of "this", there must be something more that allows using current instance as first argument of setter, the glue code seems to be missing.

Collapse
 
smalluban profile image
Dominik Lubański

The change is simple. You can think of this keyword as a different type of argument of the function. Instead of using it, we can expand the arguments list by passing the context (in actual getter/setter property definition) as the first argument (shifting rest of them).

If you want to know more, I recommend to see the implementation in the library. For example here: github.com/hybridsjs/hybrids/blob/...