gruss Janick,
Kann ich mittels JavaScript zur Laufzeit den Code einer Funktion erweitern?
nein, das geht nicht ...
Also aus
function DoSth() {
alert("nein");
}
>
> soll werden
> ~~~javascript
function DoSth() {
> alert("ja");
> alert("nein");
> }
... eine mögliche Variante des »method modyfying«s in JavaScript würde
beispielsweise die originale [DoSth]
-Referenz unter zuhilfenahme des
Module-Patterns so überschreiben, dass neue Funktionalität zusammen mit
der originalen [DoSth]
-Methode auf ihr abgebildet wird ...
... code:
function DoSth() {
alert("nein");
}
alert(DoSth);
DoSth();
DoSth = (function (formerDoSomething) { // closure
return (function () { // method modifyer
alert("ja");
formerDoSomething();
});
})(DoSth);
alert(DoSth);
DoSth();
so long - peterS. - pseliger@gmx.net
--
»Because objects in JavaScript are so flexible, you will want to think differently about class hierarchies.
Deep hierarchies are inappropriate. Shallow hierarchies are efficient and expressive.« - Douglas Crockford
ie:( fl:) br:> va:( ls:& fo:) rl:) n3;} n4:} ss:} de:µ js:} mo:? zu:]
»Because objects in JavaScript are so flexible, you will want to think differently about class hierarchies.
Deep hierarchies are inappropriate. Shallow hierarchies are efficient and expressive.« - Douglas Crockford
ie:( fl:) br:> va:( ls:& fo:) rl:) n3;} n4:} ss:} de:µ js:} mo:? zu:]