4
So habe ich eine Datenstruktur wieKann ich in diesem Zusammenhang auf den Schlüssel verweisen?
this.PauseFunctions = {
2: {
OnSlideTo: function() {
console.log("The OnSlideTo function of the event at the 2-second mark was called");
},
OnSlideAway: function() {
console.log("The OnSlideAway function of the event at the 2-second mark was called");
}
},
5: {
OnSlideTo: function() {
console.log("The OnSlideTo function of the event at the 5-second mark was called");
},
OnSlideAway: function() {
console.log("The OnSlideAway function of the event at the 5-second mark was called");
}
}
};
und ich frage mich, wenn ihr möglich für mich auf den Schlüssel, dessen Wert zu beziehen ist das Objekt, mit dem OnSlideTo
Funktion. Zum Beispiel in
2: {
OnSlideTo: function() {
console.log("The OnSlideTo function of the event at the 2-second mark was called");
},
OnSlideAway: function() {
console.log("The OnSlideAway function of the event at the 2-second mark was called");
}
}
Ich frage mich, ob es einen Weg gibt es
2: {
OnSlideTo: function() {
console.log("The OnSlideTo function of the event at the " + key + "-second mark was called");
},
OnSlideAway: function() {
console.log("The OnSlideAway function of the event at the " key + "-second mark was called");
}
}
zu
zu ändern, in demkey
2
ist so, dass mein Programm allgemeinere und wartbar sein.
, dass jedes Objekt ausgewertet wird nicht möglich, da der Weg ist. –
Warum brauchen Sie Baumfunktionen wo sind sie dann? – Amit