Code:
class ArrowFunction {
constructor (thisArg) {
this.thisArg = thisArg;
}
// Creates arrow function
static create(thisArg) {
return new this(thisArg)
}
function(func) {
this.func = func;
return this;
}
execute(...args) {
if (typeof this.func === 'function') {
this.func.apply(this.thisArg, args);
}
return this;
}
}
Code:
ArrowFunction
.create(this)
.function(function (text) {
console.log(`Text: ${text}`);
})
.execute('ein simpler Text')
.execute('noch einmal');
Die Ausgabe ist dann:
Text: ein simpler Text
Text: noch einmal
Die funktion wurde mir vor paar monaten verkauft, ich kann leider nicht viel damit anfangen, da ich selber nicht der experte in sachen coding bin, deshalb teile ich sie hier mit euch. Alles ist so aufgebaut, dass jemand der gut coden kann es modular erweitern kann und expandieren.
Ich hoffe habt spass damit





