---
# System prepended metadata

title: 練習 - 賦值運算子與記憶體觀念
tags: [JS 直播班 - 每日練習]

---

---
title: 練習 - 賦值運算子與記憶體觀念
tags: JS 直播班 - 每日練習
---

練習 - 賦值運算子與記憶體觀念
===
問題一
---
了解賦值運算子，並計算出最後 console.log 印出的結果
```javascript=
let a = 1;
let b = 2;
a += 30;
a--;
b - 1;
a -= b;

console.log(a);
console.log(b);
```
- 解答
```javascript=

let a = 1;
let b = 2;
a += 30;  // a = a +30;   31
a--;      // a = a - 1;   30
b - 1;    // 1;           未被賦予給b
a -= b;   // a = 30 - 2;  28

console.log(a);   // 28
console.log(b);   // 2
```

問題二
---
請說明以下程式碼最後共有幾個記憶體空間
```javascript=
let a = '3';
let b = 3;
let c = a*b;
a + 1;
```
- 解答
![](https://i.imgur.com/cBjEm4w.png)