運算子


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

[Release Notes] 20210204_v1 - Add explore page

[Release Notes] 20210204_v1 - Add explore page

PHP & CGI 相關知識

PHP & CGI 相關知識

[BE101] 資訊安全

[BE101] 資訊安全


Comments