I have some code where there is a “var Signature” in one file (File A). And in the same File A a method is created “Signature.prototype.PreSaveSignature = ..”.
And then in a second file (File B), the same method is created “Signature.prototype.PreSaveSignature = ..”.
Now in IE8 and below it executes the method in File B … while in IE9 it executes the method in File A. Howecome? Is there any valid reason for having two methods with same name using prototype?
You cannot have two different methods on the same prototype with the same name. The one that is defined last will be in operation for objects created in the future. You can think of
Signature.prototype.PreSaveSignatureas a storage slot for a method pointer. It can only hold one value and whichever value was last assigned to that storage slot is the one that will be used for signaturesSignature()objects.If you are getting different behavior in different browsers, that is either because you are getting different errors in one browser versus the other or you are getting different load and execution timing in the different browsers with something dynamically loaded.