How can I dynamically render a variable name in dot notation? : <p>I am not sure how to accurately describe this issue, but the code should suffice. This code is in React.js, but I think it is a JavaScript question more than anything. I have a variable initialization: </p>

<pre><code>const key = this.state.key;
</code></pre>

<p>This will evaluate to one of three strings...title, author, or year.
How can I use this variable in the following block?</p>

<pre><code>let filteredBooks = books.filter(
  (book) =&gt; {
    return book.key.toString().toLowerCase().indexOf(this.state.query) !== -1;
  }
);
</code></pre>

<p>Book has properties title, author, and year... that I want to query, and I would rather not switch through the possible values of key(only 3 right now), in case I want to scale with more properties for the book object later. How can I dynamically reference key, and render it on the fly to either title, author, year, or any other property that key might be. (key is not a property of book). I have tried book.eval(key), but this throws an "undefined is not a function" compilation error at eval(key). Once again, I am using React.js but I am thinking this is a general Javascript question. Thanks!</p>
