運算子


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

JavaScript - GoToTop 作法

JavaScript - GoToTop 作法

學習 Git (9) - 遠端數據庫 GitHub

學習 Git (9) - 遠端數據庫 GitHub

遠端主機部署心得筆記

遠端主機部署心得筆記


Comments