[Javascript] help with test program.

brian mahoney wobbly at optonline.net
Fri May 9 21:35:38 CDT 2008


Hi,

I'm pretty new to JavaScript and just purchased "JavaScript: The Good  
Parts".

Here is the code from the book.  I also tried copying it from the  
online source and have the same problem:

// Create myObject. It has a value and an increment
// method. The increment method takes an optional
// parameter. If the argument is not a number, then 1
// is used as the default.

var myObject = {
     value: 0;
     increment: function (inc) {
         this.value += typeof inc === 'number' ? inc : 1;
     }
};

myObject.increment(  );
document.writeln(myObject.value);    // 1

myObject.increment(2);
document.writeln(myObject.value);    // 3

The problem is that firebug reports:
missing } after property list
  value : 0;\n

Can anyone see the problem?

Thanks,

Brian



More information about the Javascript mailing list