運算子


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

滲透測試重新打底(3.2)--論Web入侵之SQL injection

滲透測試重新打底(3.2)--論Web入侵之SQL injection

JavaScript 五四三 Ep.07 Array.prototype.indexOf()

JavaScript 五四三 Ep.07 Array.prototype.indexOf()

The introduction and difference between class component and function component in React

The introduction and difference between class component and function component in React


Comments