|
Subject:
|
Need help with inheritance
|
|
Posted By:
|
filip
|
Post Date:
|
8/17/2006 8:32:26 AM
|
Hi!
On page 108, you write "this.newMethod = ClassA;"
However, on page 109, you write "ClassB.prototype = new ClassA();"
Could you please explain why you have the new keyword in the second case, and no new keyword in the first place.
Please help help help
Thanks :)
|
|
Reply By:
|
nzakas
|
Reply Date:
|
8/25/2006 9:38:47 PM
|
Filip,
The "new" operator is used to instantiate an instance of an object. So "new ClassA()" creates a new object of the type ClassA. Without "new", ClassA is just a pointer to a function.
Nicholas C. Zakas Author, Professional JavaScript for Web Developers (ISBN 0764579088) http://www.nczonline.net/
|