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
  • 819
  • 1
  • 10
  • 20

1 Answers1

7

Square bracket notation:

Subject['someString']();

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

karim79
  • 334,458
  • 66
  • 409
  • 405