3.3 Declaring Objects

Use one of the following methods to declare a new object in the scripting environment:

  • Declare an object and assign it properties:

    var obj = new Object()
    obj.foo('bar')
    obj.num('45')
    obj.printit = function() { writeln( 'foo=' + this.foo + ', num=' + this.num ) }
    
  • Alternatively, declare an object with properties:

    var obj = 
    {
        foo: 'bar',
        num: 45,
        printit: function(){writeln( 'foo=' + this.foo + ', num=' + this.num ) }
    }