topical media & game development

talk show tell print

#javascript-code-19-objects.js / js



  // Creates a new Object object and stores it in 'obj'
  var obj = new Object();
  
  // Set some properties of the object to different values
  obj.val = 5;
  obj.click = function(){
      alert( "hello" );
  };
  
  // Here is some equivalent code, using the {…} shorthand
  // along with key-value pairs for defining properties
  var obj = {
  
      // Set the property names and values use key/value pairs
      val: 5,
      click: function(){
          alert( "hello" );
      }
  
  };
  
  


(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.