|
Subject:
|
Why is this method placed in
|
|
Posted By:
|
filip
|
Post Date:
|
8/22/2006 7:58:45 AM
|
On p.464 In Professional Javascript:
oXmlDom.parseError = { valueOf: function () { return this.errorCode; }, toString: function () { return this.errorCode.toString() } };
Why is this object defined in the XmlDom() constructor after the oXmlDom object has been instantiated?
Why not just defined it like this:
Document.prototype.parseError = { valueOf: function () { return this.errorCode; }, toString: function () { return this.errorCode.toString() } };
Please someone must answer
|
|
Reply By:
|
nzakas
|
Reply Date:
|
8/25/2006 9:40:26 PM
|
If you were to do it your way, the same parseError object would be used for every instance of an XML Document, meaning that you would never know which DOM object it referred to.
The parseError object has to be created after the XML DOM object has been created to make sure it refers just to that object.
Nicholas C. Zakas Author, Professional JavaScript for Web Developers (ISBN 0764579088) http://www.nczonline.net/
|