I am trying to understand the different between the following codes..
Select.prototype.create = function(){
codes1......
}
Search.prototype.create = function(){
codes2......
}
They both have different codes but the same method. I am not sure why and how it works. Can anyone helps me about it? Thanks alot.
Javascript functions/methods are not unique by the name only. The whole definition, Search.prototype.create, should be unique. I say should be because Javascript allows you to replace definitions without causing any errors/warnings
Javascript sees two methods, one on the Search prototype chain, and the other on the Select prototype. These two methods just happen to be called the same but are unrelated according to the language.
Often, in any other language or API, there are common names used like
length, toString, call, dispose, replaceand the list could go on.