为什么在JavaScript中打印12而不是10 ?



每次我尝试这样做时,控制台日志打印12而不是10:

let number1 = 3;
let number2 = 2;
number1 += number2;
number2 += number1;
let result = number1 + number2;
console.log(result);

let number1 = 3; 
let number2 = 2; 
number1 += number2;
// number1 = 3 + 2 = 5; 
number2 += number1;
// number2 = 2 + 5 = 7; 
let result = number1 + number2;
// result = 5 + 7 = 12;

console.log(result);

为什么结果是10?

相关内容

  • 没有找到相关文章

最新更新