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?

1
  • Do you have string 'books()' i.e. with brackets or just 'books'? Commented Jul 11, 2013 at 12:10

1 Answer 1

7

Square bracket notation:

Subject['someString']();

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.