0

I have this

Subject.books()

that works great, but now at one place in code i just have the string 'books()', this string could basically be anything you want, i just want it to eval and evaluate the function and give me the same result as above. How do i do it?

user1323136
  • 889
  • 2
  • 11
  • 20

1 Answers1

7

Square bracket notation:

Subject['someString']();

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects

karim79
  • 339,989
  • 67
  • 413
  • 406