title: Best way to pass a guid from a javascript function as a value not a reference?
body: <p>I have a function to generate guids for testing:</p>
  
  <pre><code>helpers.guid = function(){
    var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        var r = Math.random()*16|0, v = c == 'x' ? r : (r&amp;0x3|0x8);
         return v.toString(16);
    });   
    return guid;
  };
  </code></pre>
  
  <p>I call it with:</p>
  
  <pre><code>var thisTest.guid1 = helpers.guid();
  var thisTest.guid2 = helpers.guid();
  </code></pre>
  
  <p>The problem is each time I refer to thisTest.guid1 it's a different guid.  I need to set the object property to a permanent value and I'm not sure how to do that.  I've tried adding a closure but couldn't get it to work.</p>
  
  <p><strong>Edit:</strong> to clarify, i need to be able to generate multiple guids and assign each one to a different variable.  Right now each time I refer to a variable i get a new guid as it presumably calls the function again and returns a new value.  I need "guid1" and "guid2" to be the same values each time then are used.</p>