title: When using a string to call a function from another function, how would one go about it?
body: <p>For clarity:</p>
  
  <p>The user will never be expected to input code. User inputs, aside from name customization (which customized names will NEVER be run through code), will be limited to button presses (which will then potentially activate functions which are waiting in the database entries).</p>
  
  <p>I have one defined constructor in my javascript code, and essentially will have a database which allows the user certain inputs, be they pre-defined inputs (the majority of the time) which will execute other code or customized inputs (which would never have the potential to change anything which can execute code).</p>
  
  <p>An example would be the following code: <code>new DatabaseItem("511", ["feat", "general", "1"], "Armor Proficiency", ["description", "if(database[5][0][0].returnData().includes(0)){possible=["500","Cancel"];database[5][0][0].forEach(function tempFunction(value,index){if(value==0){possible.push(index);}});}else{database[5][0][0].addTrait("invalid");alert("No eligible targets. Please select another feat.");}"])</code></p>
  
  <p>which would create a new DatabaseItem at position 511 with traits "feat", "general", "1"; the title "Armor Proficiency"; and data of "description" and would execute the following code when triggered:</p>
  
  <pre><code>if(database[5][0][0].returnData().includes(0)) {
      possible = ["500", "Cancel"];
      database[5][0][0].forEach(
          function tempFunction(value, index) {
              if(value==0) {possible.push(index);}
          }
      );
  } else {
      database[5][0][0].addTrait("invalid");
      alert("No eligible targets. Please select another feat.");
  }
  </code></pre>
  
  <p>Then after the user selects a choice (be it "Cancel", or one of the valid indexes) supposing that choosing this was valid in the first place, it would then execute more code based on the user's choice.</p>
  
  <p>Based on what I've read, the eval() function would work (but is generally considered unsafe) but Function() may also work. What would be the recommended course of action?</p>
  
  <p>Relevant information:</p>
  
  <p>-this is a stand-alone webpage-based application. The framework is provided in the html file, and this is an excerpt from the js file.</p>
  
  <p>-nothing is stored after the webpage is closed. Save data is generated via a savestring which implements changes the user makes and the positions of said changes, which the user is then free to copy to a text file. Invalid savestrings would be rejected by the loader.</p>