Hallo,
es geht nicht darum, einen Prototypen zu verändern, sondern darum, ein Objekt nachträglich zu erweitern. Und es geht vor allem darum, dass
obj = function() {
this.objMethode = function() { ... }
...
}
>
> etwas anderes ist, als
>
> ~~~javascript
obj = function() {
> ...
> }
> obj.prototype.objMethode = function() { ... }
"Prototype is the template of the class; which applies to all future instances of it. Whereas this is the particular instance of the object.
"
"I believe that @Matthew Crumley is right. They are functionally, if not structurally, equivalent. If you use Firebug to look at the objects that are created using new, you can see that they are the same. However, my preference would be the following. I'm guessing that it just seems more like what I'm used to in C#/Java. That is, define the class, define the fields, constructor, and methods."
Gruß
jobo