title: How can I set the prototype when I don't know the name of the constructor?
body: <p>It was my understanding that every javascript object had a prototype even if it were just the one from Object.prototype</p>
  
  <p>I have an asp.net webservice proxy that gets me participant data from the server. That part works fine. Here's the code:</p>
  
  <pre><code>        atomWebServiceProxy.GetInteractionParticipants(interactionId,
              function (participantsResult) {
                  var assetId, pendingPathFetches;
                  participants = participantsResult;
                  pendingPathFetches = participants.length;
                  document.title = participants.length + " participants:";
                  for (var i = 0; i &lt; participants.length; i++) {
                      assetId = participants[i].ASSETID;
                      document.title += " " + participants[i].DISPLAYID;
                      atomWebServiceProxy.GetInteractionPath(interactionId, assetId,
                          function (pathResult, participant) {
                              participant.path = pathResult;
                              pathResult.participant = participant;
                              if (--pendingPathFetches == 0) {
                                  setTimeout(afterInit, 20);
                              }
                          },
                          function (error, participant) {
                              alert(participant.DISPLAYID + " reported this error: " + error.get_message());
                          },
                          participants[i]
                      );
                  }
              },
              function (error) {
                  alert(error.toString());
              });
  </code></pre>
  
  <p>You may notice that there are nested calls and I have added a path property to each participant object, expressing in an object model the fact that it is the path data for that particular participant. This also works fine.</p>
  
  <p>Then I tried to add a method to the prototype like this:</p>
  
  <pre><code>var foo = participants[0];
  foo.prototype.redraw = function(map) {
     ... //code that redraws
  };
  </code></pre>
  
  <p>To my great surprise, I got an exception claiming that prototype is null:</p>
  
  <blockquote>
    <p>JavaScript runtime error: Unable to set property 'redraw' of undefined
    or null reference</p>
  </blockquote>
  
  <p>What is going on here? </p>
  
  <p><a href="https://stackoverflow.com/questions/14545210/why-prototype-is-undefined">This question</a> seems to address the problem but I cannot see how to apply this information to this situation, since I do not know how to refer to a constructor that is not defined in my code.</p>
  
  <p>In case this is useful info, inspection of participants.constructor in the immediate window at run-time appears to indicate that the constructor was Array()</p>
  
  <p>Should I write a constructor that copies the fields into an object and sets a prototype? If so is there a javascript equivalent to C# reflection so I don't have to rewrite this for every type of query result object? NOTE coma answered this part of the question in comments while I was updating the question.</p>