DEV Community

Discussion on: Progmattic method chaining

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Ah it's so obvious now that you show me, eval type thing nice!!

Thread Thread
 
abhinav1217 profile image
Abhinav Kulshreshtha • Edited

According to MDN docs, its not exactly eval. Every function in js is an object of Function class, so this is just manual work to implement same thing.

One drawback is that this will create an object everytime for execution and mark it for garbage collection, so if you have a fix set of functions that just needs to be called dynamically, use conditional logic like `if ('add') { this.add()}