Inheriting a Javascript Function -


I have a JS definition that In the Js file that is included in my .html file.

  function chat () {this.sendNew () = function () {[..]}}  

Now I have another. I would like to add a JS file which can extend it function chat () {this.anotherMethod = function} {}}

Is it possible? if so, how? :

You can add methods / attributes for the object to the .prototype :

  chat.prototype.anothermethod = function () {// ...}  

Just remember that .prototype Is a property of actions, and then should be used by chat , and not one of its examples.

You can read more about .prototype .


Comments