---
# System prepended metadata

title: "\U0001F3C5 Day 14 - 物件取值"
tags: [JS 直播班 - 2024 秋季班]

---

# 🏅 Day 14 - 物件取值

在物件內新增、修改、取得屬性的方法有以下兩種:

1. 點記法 (Dot notation)

```javascript=
let obj = {};
obj.key = "value";  // 新增或修改
console.log(obj.key); // 取得
```

2. 括弧記法 (Bracket notation)
```javascript=
let obj = {};

// 當屬性的值帶有小數點、空格或是數字時可以使用，記得要加上引號 (單引號或雙引號皆可)
obj['k e y'] = "value";  // 新增或修改
console.log(obj['key']); // 取得
```

### 題目

請觀看下方程式碼，依照註解敘述完成程式碼（補上 `...` 的部分）：

```javascript=
let weather = {
  country: "高雄",
  "PM2.5": 35,
  isSunny: false,
  rainingRegion: ['鼓山', '鹽埕', '旗津'],
  rainFall: {
    鼓山: 400,
    鹽埕: 300,
  }
} 

// 取得 country 的值，並使用 console.log 印出
console.log(...); 

// 取得 "PM2.5" 的值，並使用 console.log 印出
console.log(...);

// 取得 isSunny 的值，並使用 console.log 印出
console.log(...); 

// 取得 rainingRegion 陣列的第一個值 '鼓山'，並使用 console.log 印出
console.log(...); 

// 在 rainFall 新增一個屬性名為「旗津」、設定值為 200，並，並使用 console.log 印出 rainFall 的值
...
console.log(rainFall);
```



## 回報流程

將答案寫在 CodePen 並複製 CodePen 連結貼至底下回報就算完成了喔! 
解答位置請參考下圖（需打開程式碼的部分觀看）

![](https://i.imgur.com/vftL5i0.png)

<!-- 解答：  

// 取得 country 的值
console.log(weather.country);  // 方法一
console.log(weather["country"]);  // 方法二


// 取得 "PM2.5" 的值
console.log(weather["PM2.5"]); 


// 取得 isSunny 的值
console.log(weather.isSunny);  // 方法一
console.log(weather["isSunny"]);  // 方法二


// 取得 rainingRegion 陣列的第一個值 '鼓山'
console.log(weather.rainingRegion[0]); 


// 在 rainFall 新增一個屬性名為「旗津」、設定值為 200，並輸出結果
weather.rainFall.旗津 = 200; // 方法一
console.log(weather.rainFall);

weather["rainFall"]["旗津"] = 200; // 方法二
console.log(weather["rainFall"]);
-->




回報區
---
| #   | Discord | CodePen / 答案 |
| --- | ----- | ----- |
| 01  | voke  | [CodePen](https://codepen.io/FiSi-the-lessful/pen/eYqBwOv) | 
| 02  | Jainee  | [CodePen](https://codepen.io/Jainee0110/pen/qBemOmP) | 
| 03  | 泊岸  | [CodePen](https://codepen.io/qoq77416416/pen/OJKmNgO?editors=0012) | 
| 04  | haojugn  | [CodePen](https://codepen.io/hjxu/pen/xxvdpra) | 
| 05 | yuyuhunter_0509 | [CodePen](https://codepen.io/KRcube/pen/dyxWqdL?editors=0012) | 
|06|Hailey|[CodePen](https://codepen.io/sxbokfja-the-flexboxer/pen/gOVWdVw?editors=0111)|
|07|tim|[CodePen](https://codepen.io/jskrtivy-the-animator/pen/GRVmXVq?editors=0011)|
|08|雪粒| [CodePen](https://codepen.io/bzykdfhw-the-bashful/pen/qBemJNW) | 
|09|邵|[Codepen](https://codepen.io/ukscrlno-the-typescripter/pen/ZEgKqeV?editors=0011)|
|10|david1819|[Codepen](https://codepen.io/David-Lin-the-vuer/pen/WNVjady)|
|11|a1phaki(小k)|[CodePen](https://codepen.io/a1phaki/pen/XWvRxZL?editors=1111)|
|12|Mike|[CodePen](https://codepen.io/mike2049/pen/wvVdYEj?editors=0011)|
|13|Lotte|[CodePen](https://codepen.io/hmkdoxuj-the-decoder/pen/xxvdymZ?editors=0012)|
|14|朋仔|[CodePen](https://codepen.io/YPHUANG/pen/xxvdyoV?editors=0011)|
|15| JRz |[CodePen](https://codepen.io/JRZHENG/pen/JjgNeLy?editors=1111)|
|16|brucelee0629| [CodePen](https://codepen.io/xxhdklwi-the-decoder/pen/yLmbQpN?editors=0011) | 
|17|mercury2508.| [CodePen](https://codepen.io/Mercury2508/pen/KKOmbPM) |
|18|嚼勁先生| [CodePen](https://codepen.io/James520284/pen/qBemLby) |
|19| Ruby | [CodePen](https://codepen.io/xivgaijl-the-selector/pen/MWNmZZV) |
|   20  | chris      | [CodePen](https://codepen.io/chris-chen-the-selector/pen/VwobgXK?editors=0010) | 
| 21 | 毛巾 | [CodePen](https://codepen.io/bqdcjboa-the-solid/pen/zYgwbZB) |
|  22   |   610    | [CodePen](https://codepen.io/YI-LING-LIU/pen/mdNmgLd) |
|23|陳睿睿|[CodePen](https://codepen.io/uwmrsusb-the-solid/pen/PoMmvyO?editors=0011)|
|24| Dolce_墨|[CodePen](https://codepen.io/DolceTseng1026/pen/NWQjVEB)|
|  25   |     Celine  | [CodePen](https://codepen.io/szuning/pen/gOVWJqX) | 
|  26   |     ycl325.etheddie  | [CodePen](https://codepen.io/wdvikfuz-the-selector/pen/PoMmrPa) 
|  27   |     Rogan  | [CodePen](https://codepen.io/RoganHsu/pen/ExqmBVK?editors=1111) 
|  28   |     是在哈囉  | [CodePen](https://codepen.io/miyxdhem-the-solid/pen/jOgmjro?editors=1112) | 
| 29 | Mos |[CodePen](https://codepen.io/mos25399/pen/XWvRvNz?editors=0010)|
| 30 | yuyeh_1212 | [CodePen](https://codepen.io/yuyeh1212/pen/XWvgrXo) |
| 31 | Sonia | [CodePen](https://codepen.io/YUJOU/pen/yLmXBVq?editors=0011) |
| 32 | 倫倫 | [CodePen](https://codepen.io/f5badapple/pen/qBejWxd?editors=0011) |
| 33 | jimmy.0706 | [CodePen](https://codepen.io/JimmyMao/pen/ZEgyzjZ?editors=0012) |
| 34 | yuling  | [CodePen](https://codepen.io/yu-ling-peng/pen/RwXgwJB?editors=0011) | 
| 35 | GTR150 | [CodePen](https://codepen.io/Wer-Qwe/pen/WNVONLe?editors=1111) | 
|  36   |   JIA    | [CodePen](https://codepen.io/nzaicwlw-the-styleful/pen/eYqRmVy?editors=0010) | 
| 37 | GAVI | [CodePen](https://codepen.io/qbafldcv-the-scripter/pen/zYgzGbY?editors=0010) | 
|  38  |jerry_66983 | [CodePen](https://codepen.io/Barry-C/pen/xxvrRJx?editors=0011) | 
|  39  |kaka_945 | [CodePen](https://codepen.io/kay945/pen/PoMjWOd) |
|  40  |CrystalLala | [CodePen](https://codepen.io/crystallala/pen/RwXgKdY) |
|  41  | Kaya | [CodePen](https://codepen.io/kayaribi/pen/dyxRWyx) |
|  42   |   Ariel    | [CodePen](https://codepen.io/ariel0510/pen/rNXwmoE?editors=0011) |
|  43   |  alec1203   | [CodePen](https://codepen.io/soloayaya/pen/LYwLLMO?editors=1112) |
| 44 |ABOOS| [CodePen](https://codepen.io/guhungyin/pen/MWNoRYy?editors=0012) | 
| 45 |ab567ab5| [CodePen](https://codepen.io/WanTzu-Chiang/pen/BaXdzpx?editors=0011) |
|  46   |    蘑菇星星   | [CodePen](https://codepen.io/brrrieon-the-vuer/pen/QWeMOjB?editors=0012) | 
|  47   |    ABow_Chen   | [CodePen](https://codepen.io/fred39392001/pen/ExqvoYZ) | 
|  48   |    Seris   | [CodePen](https://codepen.io/Dale-Chien/pen/xxvLMNv) | 
|   49  |   Emma    | [CodePen](https://codepen.io/Emma0919/pen/poMrMzz) | 
|  50   |   KUN.   | [CodePen](https://codepen.io/barry91205/pen/jOgGqMB?editors=1111) | 
| 51 | Jim | [CodePen](https://codepen.io/JimChou/pen/YzmrpOz?editors=0011) |
|  52   |   Ed Huang   | [CodePen](https://codepen.io/yide1986/pen/OJKxWwv) | 
|  53   |   Ana    | [CodePen](https://codepen.io/Ana-Wu/pen/OJKxZvq?editors=0011) | 
|  54   | yaoling.liang | [CodePen](https://codepen.io/Yao-Ling-L-/pen/oNKGREV?editors=1012) | 
|55|陳小廷| [CodePen](https://codepen.io/ting1124/pen/xxvPREW) | 
|56|xiang5141| [CodePen](https://codepen.io/XIANG-XIANG/pen/poMdNQr?editors=0010) | 
|57|yu| [CodePen](https://codepen.io/yu_ch12/pen/zYgPzdX) | 
|58|Joannehu| [CodePen](https://codepen.io/nelbabkv-the-flexboxer/pen/oNKoeoe?editors=1011) | 
|59|joylu0902| [CodePen](https://codepen.io/joylu0902/pen/PoMOQvZ) | 
| 60 | Glen_69515 | [CodePen]() | 
|61|Tatsu| [CodePen](https://codepen.io/chindesu0207/pen/mdNLwez) | 
|62|Yen| [CodePen](https://codepen.io/yuxxxlouyen/pen/XWvqVMP) | 
|63|野鴿| [CodePen](https://chatgpt.com/c/67231d87-a864-8003-9635-f89d4fddc232) |
|64|Hedwig| [CodePen](https://codepen.io/adirehfz-the-encoder/pen/qBeKWmb?)|
|65|維妮|[CodePen](https://codepen.io/Maggy-Lin/pen/VwoBPxQ)|
|66|iamcan|[CodePen](https://codepen.io/uhnxswdq-the-typescripter/pen/GRVXLQe)|
|67|zobody|[CodePen](https://codepen.io/Zoe-Shih/pen/mdNGZZL)|
|68|KOMATSU PEI|[CodePen](https://codepen.io/Komatsu2021/pen/gOVQpZP?editors=0010)|
|69|Nocab Wang ( 培根 )|[CodePen](https://codepen.io/PeihanWang/pen/eYqbeZM?editors=0011)|
|70|Amy(咂摳)| [CodePen](https://codepen.io/nnxucgmc-the-builder/pen/rNXRwRK?editors=0011) | 
|71|Satar| [CodePen](https://codepen.io/SatarKuo/pen/XJrpEbx?editors=0011) | 
|72|ji3di|[CodePen](https://codepen.io/jwuuhtxh-the-builder/pen/EaYmJbY?editors=0011)
|73|Chuang|[CodePen](https://codepen.io/uidoytjq-the-solid/pen/vEBdWYK?editors=0011)
<!-- 可複製下方格式
|     |       | [CodePen]() | 
-->