Unable To Implement Module Pattern
Solution 1:
You are trying to execute the result of a function as a function, and are assigning values to functions. Try:
var seqer = serial_maker;
seqer.set_prefix('Q');
seqer.set_seq(1000);
var unique = seqer.gensym();
Also see this jsFiddle
Solution 2:
There are two errors in this code example:
The definition of serial_maker is finished with () which invokes the anonymous function. That makes the next line:
var seqer = serial_maker();
erroneous since serial_maker is not the function but the object returned by the anonymous function.
Once the previous error is fixed the two lines:
seqer.set_prefix = 'Q'; seqer.set_seq = 10000;
should change to:
seqer.set_prefix('Q'); seqer.set_seq(10000);
(Source: http://oreilly.com/catalog/errata.csp?isbn=9780596517748&order=date)
Solution 3:
I am currently working through the book and I see a redundant pair of parentheses () in your posted code, when I compare it to the book. You have:
}
};
}( );
it should be:
}
};
};
Along with, the additional answers where the 'Q' and the 1000 need to be wrapped in ().
Post a Comment for "Unable To Implement Module Pattern"