Ich möchte wie mit Bs und umgekehrt austauschen, die mehrmals in einer Zeichenfolge angezeigt werden.Tauschen Wörter in JavaScript
function temp(a,b) {
console.log('The first is ' + b + ' and the second is ' + a + ' and by the way the first one is ' + b);
}
temp('a','b')
eval(temp.toString().replace('first','second'));
eval(temp.toString().replace('second','first'));
temp('a','b');
Dies funktioniert nicht, aber ich mag folgendes Ergebnis erhalten:
The first is a and the second is b and by the way the first one is a
warum nicht 'Temp ('b', 'a')?' –