Error in an example from book - "Unexpected token {" <p>I was reading a book on JavaScript (recently started to learn). While running one of the examples from a book, I get an error. I'm using Chromium browser on Ubuntu, 14.0.835.202.</p> <p>Since I'm a newbie, I can't understand why there is an error. Thanks in advance.</p> <pre><code>Function.prototype.method = function (name, fn) { this.prototype[name] = fn; return this; }; var Person { this.name = name; this.age = age; }; Person. method ("getName", function { // error here - "Uncaught SyntaxError: Unexpected token {" return this.name; }). method ("getAge", function { return this.age; }); var alice = new Person ("Alice", 93); var bill = new Person ("Bill", 30); Person. method ("getGreeting", function { return "Hi" + this.getName() + "!"; }); alert (alice.getGreeting()); </code></pre> <p>EDIT:</p> <p>The solution gave me another question that I wanted to ask. For object declaration:</p> <pre><code>var Object = function (...) // line 1 { // code here }; </code></pre> <p>if the number of variables is so big that I don't want to list them in line 1, what can I do?</p>