Can I have an array/map of method names which represent an ordinarily chainable method call
[['add'],['subtract']]
And have them build up the chain progmatticaly, can you provide some pseudo code?
Can I have an array/map of method names which represent an ordinarily chainable method call
[['add'],['subtract']]
And have them build up the chain progmatticaly, can you provide some pseudo code?
For further actions, you may consider blocking this person and/or reporting abuse
kambala yashwanth -
Ben Lovy -
Felipe Armoni -
Bruce Axtens -
Once suspended, adam_cyclones will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, adam_cyclones will be able to comment and publish posts again.
Once unpublished, all posts by adam_cyclones will become hidden and only accessible to themselves.
If adam_cyclones is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Adam Crockett.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag adam_cyclones:
Unflagging adam_cyclones will restore default visibility to their posts.
Top comments (4)
Something like metaprogramming?
There is an old trick we used at old work, which uses
Function.prototype.call
. You can use an object of Function class itself to call dynamic functions from string. linkThere is a stackoverflow page I have saved on same topic. There are few different tricks mention there, I have tried both
Function
class trick andHandler
class trick. I have not used thewindows
object trick because I feel it is exposing a lot of attack area to the windows object.Here is a working code
when function_to_run is 1, it will call console.warn, when it is 0, it will call console.log.
Ah it's so obvious now that you show me, eval type thing nice!!
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()}