[Javascript] object methods and prototypes
Mike Dougherty
mdougherty at pbp.com
Thu Apr 29 09:08:53 CDT 2004
Is it better to define an object with method references in the constructor or to assign methods
using the object.prototype syntax? (are more resources used for multiple instantiations of
example 1?)
Assume MyFunction() is already defined earlier:
ex 1:
function MyObj() {
/* code here */
this.Method = MyFunction()
}
ex 2:
function MyObj() {
/* code here */
}
MyObj.prototype.Method = MyFunction()
More information about the Javascript
mailing list