Recently, I have been looking deeply into JavaScript to fully understand the language and ask some egregious questions that I cannot find answers to (in particular, with object-oriented programming).
Assuming the following code:
function TestObject()
{
this.fA = function()
{
}
this.fB = testB;
function testB()
{
}
}
TestObject.prototype = {
fC : function
{
}
}
What is the difference between functions fAand fB? Do they behave the same in volume and potential ability? Is this just a convention, or is it technically better or right to some extent?
If only there will ever be one instance of an object at any given time, will the function add to the prototype, for example fC, even cost? Is there any use for this? Is a prototype really useful when working with many instances of an object or inheritance?
"" , TestObject.prototype.functionName = function(){} ?
, JavaScript , , . Java PHP - , JavaScript, , .