次対のjavascript:オペレータ間の戻り値の差 - 及び - 以下のコードを考える=
var x = 0;
function decrement(num) {
return num--;
}
var y = decrement(x);
console.log(y); // 0
:
y--
リターン
0
機能からない理由
var x = 0;
function decrement(num) {
return num -= 1; // this is the only difference between the functions
}
var y = decrement(x);
console.log(y); // 0
y -= 1
戻る一方-1
?
なぜ私も '--y'も実行しなかったのは不思議です。しかし、あなたはおそらくこの質問の答えを見つけるでしょう:http://stackoverflow.com/questions/9549780/what-does-this-symbol-mean-in-javascript –
@DavidThomasありがとう。あなたはSOの単一の文字を簡単に検索することができなかったことを認識していませんでした。なぜ私はこの質問に対する答えを最初に見つけられなかったのか説明します。 – dtburgess
参照として実際の参照を使用してStackoverflowを参照する代わりに、https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators – Jan