###### tags: `Javascript` # 賦值運算子+=、-=、a++、a-- ## +=、-= - = 是一個重新賦予值 - `a=a+10` 等同於`a+=10`,`a+=10`是縮寫。 - `a=a-10` 等同於`a-=10`,`a-=10`是縮寫。 ```javascript= let a = 50; a = a + 10; a += 10; a = a - 10; a -= 10; console.log(a); ``` ## a++、a- - * a++ 等於 a=a+1,a- - 等於 a=a-1,每次只會累加1或累減1 * 使用情境:計分、計次數 ```javascript= let a = 0; let b = 0; a++; a++; b++; a--; console.log(a, b); ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up