---
# System prepended metadata

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

---

---
tags: JS 直播班 - 2023 秋季班
---
# 🏅 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 / 答案                                                               |
|:--------------:| ---------------------------------------------------------------------------- |
|    pinyi_9     | [CodePen](https://codepen.io/Wpypy/pen/bGzdJYq?editors=1011)                 |
|  celinelinnn   | [CodePen](https://codepen.io/celinephoebe/pen/rNPVbYZ)                       |
|     Rxzan      | [CodePen](https://codepen.io/Tzuru-Chen/pen/zYeGreV)                         |
|    ShangChu    | [CodePen](https://codepen.io/shangchu0412/pen/VwgLNxY?editors=0012)          |
|     詹姆士     | [CodePen](https://codepen.io/z111048/pen/BaMNEVW)                            |
|   runweiting   | [CodePen](https://codepen.io/weiting14/pen/oNmXOyv)                          |
|      阿榮      | [Codepen](https://codepen.io/codeitaday/pen/oNmXOPN)                         |
|     Allen      | [Codepen](https://codepen.io/hlctw/pen/BaMNEEd)                              |
|    kuanju27    | [Codepen](https://codepen.io/Eero-Chiao/pen/KKJpYJR)                         |
|     銀光菇     | [CodePen](https://codepen.io/genesynthesis/pen/mdvJgZO)                      |
|     yuling     | [Codepen](https://codepen.io/igzdflpu/pen/gOqpyVW)                           |
| xiaokui_71292  | [CodePen](https://codepen.io/pen?template=JjxdqYo)                           |
|   lychee_kk    | [Codepen](https://codepen.io/kakakala/pen/bGzdypv)                           |
|      kawa      | [Codepen](https://codepen.io/z83xji6/pen/mdvJYPm?editors=0011)               |
|  cest_jessie   | [Codepen](https://codepen.io/itsjessiechen/pen/RwvPmRp)                      |
|   jimmy.0706   | [Codepen](https://codepen.io/WeiJun-Mao/pen/ExrjzoV?editors=0010)            |
|      Ivy       | [Codepen](https://codepen.io/Irene-Ke/pen/LYqVodb?editors=0010)              |
|     yuan!      | [CodePen](https://codepen.io/townyuan/pen/qBgdGpa)                           |
|   damon0323    | [CodePen]([網址](https://codepen.io/swk9eny2/pen/oNmXRdZ?editors=0011))      |
|     CPing      | [CodePen](https://codepen.io/CPing/pen/poGJmGM)                              |
|     Lainie     | [CodePen](https://codepen.io/Lainie88/pen/gOqpJEK?editors=0012)              |
|      Oria      | [CodePen](https://codepen.io/kajing/pen/dyaoBzK?editors=0011)                |
|     Ching      | [CodePen](https://codepen.io/tzuchingg/pen/GRzJbxe?editors=0011)             |
|     claire     | [CodePen](https://codepen.io/yi-wen-chen/pen/ZEwGdoe)                        |
|     Alyce      | [CodePen](https://codepen.io/alycehwy/pen/NWoqZJx?editors=0010)              |
|     Winnie     | [CodePen](https://codepen.io/codepen-io-winnie/pen/mdvJZXv?editors=0011)     |
|     Winnie     | [CodePen](https://codepen.io/michaelhsia/pen/bGzdPPE)                        |
|      依依      | [CodePen](https://codepen.io/Rita-Yang/pen/MWLwNpQ?editors=0011)             |
|    Chia Pin    | [CodePen](https://codepen.io/joker-cat/pen/KKJpORZ)                          |
|      Andy      | [CodePen](https://codepen.io/andy31342/pen/WNPvVME?editors=0011)             |
|     shuuu      | [CodePen](https://codepen.io/afjrvjzl-the-bashful/pen/YzBXmbq?editors=0011)  |
|     Helen      | [CodePen](https://codepen.io/milkteamonster/pen/BaMoBpY?editors=0010)        |
|      白夜      | [CodePen](https://codepen.io/Wei903/pen/JjxYPeb?editors=0012)                |
|phyllis| [CodePen](https://codepen.io/Phyllis-Cheng/pen/qBgOBrV)                      |
|      OSN       | [Codepen](https://codepen.io/osncodepen/pen/zYevYBN?editors=1111)            |
|   Vivian2857   | [Codepen](https://codepen.io/uojbohed-the-solid/pen/RwvWwEd?editors=0010)    |
|     Jerry      | [CodePen](https://codepen.io/ildkosxk-the-encoder/pen/mdvedgY)               |
|      dora      | [CodePen](https://codepen.io/dorayu/pen/OJdyPLP?editors=1011)                |
|    Moreene     | [CodePen](https://codepen.io/Moreene/pen/GRzpgdZ)                            |
|     jiayu      | [CodePen](https://codepen.io/fjqxaznl-the-reactor/pen/mdveyQE?editors=1010)  |
|      Uli       | [CodePen](https://codepen.io/uli1313/pen/vYbNEvL?editors=0011)               |
|    yuan2781    | [CodePen](https://codepen.io/ismebir/pen/qBgOEGW)                            |
|      風羽      | [CodePen](https://codepen.io/Joy-Huang/pen/rNPOagP?editors=0011)             |
|    Ataraxia    | [CodePen](https://codepen.io/ataraxia8888/pen/LYqYLKP)                       |
|    ann6212     | [CodePen](https://codepen.io/yqmegupa-the-styleful/pen/WNPQvoy?editors=1012) |
|      蛋塔      | [CodePen](https://codepen.io/Hong-Game1/pen/LYqpVzZ)                         |
|  sunny_08149   | [CodePen](https://codepen.io/Sunny-Lin/pen/QWYjbgZ)                          |
|      楓仔      | [CodePen](https://codepen.io/maplestartend/pen/vYbNORJ?editors=0012)         |
|   tanuki5863   | [CodePen](https://codepen.io/tanuki320/pen/QWYjboP?editors=1011)             |
| 奔跑吧(GTR150) | [CodePen](https://codepen.io/Wer-Qwe/pen/qBgOOrV?editors=1111)               |
|    ming0712    | [CodePen](https://codepen.io/StevenHuang/pen/YzBywYz?editors=0010)           |
|      維哲      | [CodePen](https://codepen.io/kwz1202/pen/bGzVpda)                            |
|   荷菓かのり   | [CodePen](https://codepen.io/oogxwkvw-the-builder/pen/mdvePrm?editors=0111)  |
|      JUN_      | [CodePen](https://codepen.io/Jun-L/pen/yLZYOOQ?editors=1011)                 |
|    ⭐️小正     | [CodePen](https://codepen.io/colorgolden/pen/MWLaeYY)                        |
|    Fabio20     | [CodePen](https://codepen.io/fabio7621/pen/poGjbRJ?editors=0010)             |
|    QOO#8446    | [CodePen](https://codepen.io/QOOQOOQ/pen/ExrVyvX?editors=0012)               |
|      Eden      | [Codepen](https://codepen.io/iseden/pen/dyaYXLQ)                             |
|  nikkita_3544  | [CodePen](https://codepen.io/vanessa7259/pen/JjxYKLM)                        |
|      保羅      | [CodePen](https://codepen.io/paul-1997/pen/rNPOMpr?editors=0011)             |
|    gebyman     | [CodePen](https://codepen.io/gebyman/pen/YzByGjP?editors=0012)               |
|   _shun0130    | [CodePen](https://codepen.io/koba60052ww/pen/OJdyRob?editors=0011)           |
|  hsuanlee1084  | [CodePen](https://codepen.io/hsuanlee1024/pen/GRzpNNE?editors=0010)          |
|      Zem       | [CodePen](https://codepen.io/Potoro/pen/QWYjdKe)                             |
|    smalljie    | [CodePen](https://codepen.io/smalljie/pen/yLZYgBB)                           |
|    LinaChen    | [CodePen](https://codepen.io/LinaChen/pen/JjxYRjB)                           |
|       MY       | [CodePen](https://codepen.io/ahmomoz/pen/wvNKgNv?editors=1111)               |
|     Rogan      | [CodePen](https://codepen.io/RoganHsu/pen/wvNKgrL?editors=0011)              |
|      xin       | [CodePen](https://codepen.io/Estherrrrrr999/pen/jOdbBOV)                     |
|    yu.t_liu    | [CodePen](https://codepen.io/YuT200053/pen/oNmjZZV?editors=0011)             |
|      IRIS      | [CodePen](https://codepen.io/sz594380/pen/qBgOmOE?editors=0011)              |
|     shiro      | [CodePen](https://codepen.io/chenghsienwang/pen/yLZYbMG)                     |
|   santu0868    | [CodePen](https://codepen.io/HatsumiSan/pen/MWLaYNP?editors=1010)            |
| yaoling.liang  | [CodePen](https://codepen.io/Yao-Ling-L-/pen/NWoGMVv?editors=0012)          |
|    JasonFu     | [CodePen](https://codepen.io/jie-Fu/pen/LYqprQN?editors=1010)               |
|   minnielin    | [CodePen](https://codepen.io/ShengXin-Lin/pen/QWYjZbQ?editors=1011)          |
|      zona      | [CodePen](https://codepen.io/w242920/pen/GRzpwqG?editors=1111)               |
|      MDFK      | [CodePen](https://codepen.io/maywang/pen/bGzVOvB?editors=0010)               |
|     Befun      | [CodePen](https://codepen.io/richard260572/pen/jOdWNvQ?editors=0011)         |
| 歐陽龍龍#1061  | [CodePen](https://codepen.io/dizzydog-rgb/pen/OJdMPGR)                       |
|     Tina02     | [CodePen](https://codepen.io/chjitlox-the-bashful/pen/vYbEYKP)               |
|     Yijing     | [CodePen](https://codepen.io/Yi-Jing-71080635/pen/ZEwQeOK?editors=0011)      |
|     Sponge     | [CodePen](https://codepen.io/biunpujm-the-flexboxer/pen/ExrPWMd)             |
|      noah      | [CodePen](https://codepen.io/lch1222/pen/wvNMpXG?editors=0011)               |
|      Leo       | [CodePen](https://codepen.io/Aruminiya/pen/BaMjbeE)                          |
|     peggy      | [CodePen](https://codepen.io/peggylai/pen/NWoxVZz?editors=1111)              |
|      Iris      | [CodePen](https://codepen.io/iris831206/pen/mdvVZBx)                         |
|      xuan      | [CodePen](https://codepen.io/xuan0915/pen/wvNGazJ?editors=0012)              |
|  nini1202desu  | [CodePen](https://codepen.io/tvxq5206/pen/WNPwvKM?editors=0011)              |
|    hsiu8767    | [CodePen](https://codepen.io/hsiu8767/pen/eYxZNOM?editors=0011)              |
|      Peng      | [CodePen](https://codepen.io/H-Peng/pen/KKJzzNZ?editors=0010)                |
|      精靈      | [CodePen](https://codepen.io/justafairy/pen/LYqNNbK)  |
|      hsu0921      | [CodePen](https://codepen.io/HSUANIN0327/pen/JjxXXWq) |
|      Daylily    | [CodePen](https://codepen.io/daylily/pen/XWOddyQ)  |
|      阿賀#3700    | [CodePen](https://codepen.io/sungho/details/eYxZdOd)  |
|Mattie|[CodePen](https://codepen.io/mattielin/pen/qBgZXQM)|
|阿維#2569|[CodePen](https://codepen.io/iijojpli-the-looper/pen/WNPwLKr?editors=0011)|
|      RX00      | [CodePen](https://codepen.io/llqzknqv-the-styleful/pen/MWLyRvj?editors=0011)                |
|      小廷    | [CodePen](https://codepen.io/uyxkiake-the-selector/pen/eYxZoyv?editors=0011)                |
|      Joy chiang   | [CodePen](https://codepen.io/fwysphbw-the-vuer/pen/mdvPYWJ?editors=1011)                |
|      davidtt   | [CodePen](https://codepen.io/David-Tsai/pen/WNPGGbL)                |
|      郭芙蘭＃6374   | [CodePen](https://codepen.io/flora_Kuo/pen/PoVGxzb?editors=1011)                |
|      Cosmos  | [CodePen](https://codepen.io/violet7755/pen/RwvoPaq)                |
| hsuhsusophie | [CodePen](https://codepen.io/hsuhsusophie/pen/MWLbPYK?editors=0012)                |
|Rochel|[Codepen](https://codepen.io/rochelwang1205/pen/vYbgENy?editors=1111)|
|shcopy|[Codepen](https://codepen.io/shcopy/pen/zYeZXLV)|
|_Luna|[Codepen](https://codepen.io/sfctsolp-the-sasster/pen/BaMWXmZ?editors=0011)|
| shawey.1a2b | [Codepen](https://codepen.io/Shawey/pen/abXLzeR) |
| Hank._.z | [Codepen](https://codepen.io/linoiaby-the-sans/pen/BaMmdLM?editors=1111) |
|ChrisSQR|[Codepen](https://codepen.io/ChrisSQR/pen/mdvqMrj)|
|angela9741|[Codepen](https://codepen.io/coding-angela25/pen/eYxjZga?editors=0010)
| macihuang | [Codepen](https://codepen.io/macy1215/pen/QWYBpZO) |
| bf_tsai | [Codepen](https://codepen.io/BF-Tsai/pen/ExrexGv?editors=1111) |
| NathanJames |[Codepen](https://codepen.io/ufo060204/pen/KKJxQaR)|
| skypassion5000 |[Codepen](https://codepen.io/skypassion5000/pen/eYxPVaX?editors=0011)|
| 辣椒 | [Codepen](https://codepen.io/chilichen118/pen/QWYJpQb) ||