um ehrlich zu sein, habe ich das mit den Lambdas auch
noch nicht 100%ig kapiert, ich glaube das ist noch
etwas komplizierter.
Hier nochmal dasselbe Beispiel mit flexiblen Parametern:
ActionScript:
Function.prototype.after=function(g) {
var f=this;
return function() {
return f(g(arguments));
}
}
function addTag(tag,attributes) {
var stag='<'+tag+" "+attributes+'>';
var etag='</'+tag+'>';
return function(x) {
return stag+x+etag;
}
}
res=addTag("b","class=\"classname\"").after(addTag("b"))("helo");
und Schleife mal anders:
ActionScript:
Function.prototype.loop=function(x) {
var f=this;
return function() {
for (var i=0; i<x; i++) {
f.apply(f,arguments);
}
}
}
a=function(x,y) {
trace(x+" "+y);
}
a.loop(10)("helo","world");
Sonnige Grüsse
Florian