title: Calling a method on an object retrieved from Dictionary JavaScript object
body: <p>I am trying to fill a Dictionary (JavaScript object) and retrieve values (custom objects/classes) from it using a string index. Then once I get the value from the dictionary, I need to invoke a method on this object. Unfortunately, that does not work because once it is being retrieved from the Dictionary,  it is just a simple object (<code>typeof</code> returns "object").</p>
  
  <p>So the thing I'm trying to do is to cast to the object type that was initially pushed into the dictionary, which is in my case: <code>google.visualization.Gauge</code>. (<a href="https://developers.google.com/chart/interactive/docs/gallery/gauge#Data_Format" rel="nofollow">Reference</a>)</p>
  
  <p>I tried to use <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/create" rel="nofollow">Object.create</a> but that did not work for me. Below is my code:</p>
  
  <pre><code>var _gauges = {};
  
  var methods = {
      init: function (options) {
  
          var containers = this;
  
          if (containers != null &amp;&amp; containers != undefined &amp;&amp; containers.length &gt; 0) {
              containers.each(function (index, elem) {
  
                  var id = $(elem).attr('id');
                  var name = $(elem).data('name');
                  var value = $(elem).data('value');
  
                  var data = google.visualization.arrayToDataTable([
              ['Label', 'Value'],
              [name, value]
                  ]);
  
                  var options = {
                      width: 400, height: 120,
                      redFrom: 90, redTo: 100,
                      yellowFrom: 75, yellowTo: 90,
                      minorTicks: 5
                  };
                  var cont = document.getElementById(id);
                  var chart = new google.visualization.Gauge(cont);
                  _gauges[name] = chart;
                  chart.draw(data, options);
              });
          }
  
      },
      setValue: function (gaugeName, newValue) {
          var thisGauge = _gauges[gaugeName];
          if (thisGauge) {
              thisGauge.setCell(0, 1, newValue);
              //var tmp = Object.create(google.visualization.Gauge, thisGauge);
              //tmp.setCell(0, 1, newValue);
          }
      }
  </code></pre>