function ABC(){ ... }
ABC.prototype.newMethod = function(){} //to create a new method
Then how about ABC.prototype = function() { ... } ?
Can I know what is the difference?
Printable View
function ABC(){ ... }
ABC.prototype.newMethod = function(){} //to create a new method
Then how about ABC.prototype = function() { ... } ?
Can I know what is the difference?
This is correct:
ABC.prototype.newMethod = function(){} //to create a new method
This is incorrect:
ABC.prototype = function() { ... }
What you may be looking for is:
Code:ABC.prototype = {
newMethod: function() {},
anotherMethod: function() {}
};