Jörg Peschke: Speicherplatz von "Methoden" in JavaScript

Beitrag lesen

Hallo zusammen,
Ich befasse mich zur Zeit ein bisschen mit ActionScript-Programmierung...ist ja recht ähnlich zu JavaScript.

Beim Studium der Action Script Coding Standards bin ich auf Folgendes gestossen:

"When Creating objects, attach object functions and properties that will be shared across all instances of the object to the prototype of the object. This ensures that only one copy of each function exists in memory. As a general rule, do not define functions within the constructor. This creates a copy of the same function for each object instance and unnecessarily wastes memory..."

Jetzt frage ich mich: Ist das in JavaScript genauso?
Generell halte ich nämlich die Definition von Methoden im Konstruktor für sinnvoller, als erst ein Objekt zu bauen, dem ich dann per Prototype wieder umständlich eine Funktion unterschieben muss
(es sei denn natürlich, ich will genau das tun, z.b. um Vererbung zu emulieren oder so etwas).

Wer weiß mehr darüber?