Category :

Published on :Mar 17, 2016

Do you remember we talked about ruby's send method [here]({{ site.url }}/using-send-method-in-ruby-to-refactor-conditional/). It is used to call a ruby function from string having same value as function name.

There is js equivalent of the same:

// defining the function
var apple = function(){
    console.log('apple');
}

eval('apple()') // => apple

Reference:

  1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
  2. http://www.2ality.com/2014/01/eval.html
Loading

Interested In Working Together ?

Over 8 years of industry experience in Game/Frontend
development with special interest.
Book your Consultation
© Prakash Poudel