Код: Выделить всё
function createAccount({Param1, Param2, Param3, Param4}){
for (let [Key, Value] of Object.entries(arguments[0])) {
console.log(`Before transform ${Key}: ${Value}`);
// Param1: A, Param2: B, Param3: C, Param4: D
}
// Here I need to loop over the arguments and transform their values
let count = 0
for (let [Key, Value] of Object.entries(arguments[0])) {
arguments[0][Key] = count + 1;
count += 1;
}
for (let [Key, Value] of Object.entries(arguments[0])) {
console.log(`after transform ${Key}: ${Value}`);
// Param1: 1, Param2: 2, Param3: 3, Param4: 4
}
console.log(Param1, Param2, Param3, Param4);
// Param1: A, Param2: B, Param3: C, Param4: D
//It hasn't transformed?!
}
createAccount({Param1: 'A', Param2: 'B', Param3: 'C', Param4: 'D'});
Я надеюсь, что код является самоочевидным, но в основном я пытаюсь преобразовать значения аргументов из A, B, C, D Взативно в 1, 2, 3, 4
Подробнее здесь: https://stackoverflow.com/questions/796 ... -arguments