title: Load a javascript object with its functions from file
body: <p>In a website I would like to use a javascript function to load an object from a file. I initially tried using JSON but my javascript object is complex and has functions for some parameters. Is there a way I can load the object from a file?</p>
  
  <h3>myObject.js (not valid JSON as it has a function)</h3>
  
  <pre><code>{
      "value1": "some value",
      "functionValue": function() { 
          return "function value"; 
      }
  }
  </code></pre>
  
  <h3>function to load object from file</h3>
  
  <pre><code>function getFileObject(fileURL) {
      var myObject;
  
      $.ajax({
          url: fileURL,
          type: "GET",
          datatype: 'json',
          async: false,
          success: function (result) {
              myObject = result;
          }
       });
  
       return myObject;
  }
  </code></pre>