Dynamic methods with javascript

I recently had an implementation requirement to be able to call a method given a string with the name of the method.

I came across two strategies for achieving this:

1. Eval

function a(){
alert('a called');

2. Map

function a(){
alert('a called');


  1. thanks! yes it did! saved me some time. Keep up the good work :)

  2. JavaScript Training Course is essential to the achievements of an individual. Perhaps its most positive benefit is better employees. A company develop the potential of an employee, and part of the way a company encourages improvement is through training.

    JavaScript Course
    Online Javascript Course
    Javascript Course Online
    Free Online Javascript Course

    AngularJS Interview Questions
    JavaScript Tutorials


Post a Comment

Popular posts from this blog

Android: How to change size of vector drawable image

AngularJs: User friendly date display with AngularJs and MomentJs

Nerd Tree: A File Explorer with Mac Vim