運算子


Posted by mijouhsieh on 2022-03-17

let x = 2
console.log(x)
console.log(x++)
console.log(x)
console.log(++x)
console.log(x)

X++ 和 ++x 不一樣

x++
執行順序是:先列印出 x 的數值後,再進行 x = x + 1 的動作。
++x
執行順序是:先 x = x + 1 ,再列印出 x 的數值。

運算子執行順序
程式碼連結

let x = 2
L2 L3 L4 x++ ++x x += 1 都是賦值完
才L5 印出 x,所以x是賦值完的結果 //3


#assignment operators #x++ #++x #運算子







Related Posts

RNN 進化了 - LSTM 與 GRU

RNN 進化了 - LSTM 與 GRU

TypeScript 函式定義字串型別相連和JavaScript String.prototype.concat() 的差異

TypeScript 函式定義字串型別相連和JavaScript String.prototype.concat() 的差異

[day-3]布林、undefined、null/字串數字轉換/比較與邏輯運算子

[day-3]布林、undefined、null/字串數字轉換/比較與邏輯運算子


Comments