topical media & game development

talk show tell print

#javascript-code-04-newobj.js / js



  // Set item equal to a new string object
  var item = "test";
  
  // itemRef now refers to the same string object
  var itemRef = item;
  
  // Concatenate some new text onto the string object
  // NOTE: This creates a new object, and does not modify
  // the original object.
  item += "ing";
  
  // The values of item and itemRef are NOT equal, as a whole
  // new string object has been created
  alert( item != itemRef );
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.