# DAY17 - JavaScript 5. 善用 typeof 了解變數型別 ### 什麼是 typeof ? - `typeof`,是一個可以讓開發者知道,該變數屬於那一類型別的語法: ### 參考下列程式碼: 1. 宣告變數 `a` = 1.33378 ``` let a = 1.33378 ``` 2. 輸入 `typeof a` ``` typeof a // 顯示答案: 'number' ``` ### 除了數字以外,字串'string' 也可以被查詢喔 1. 宣告變數 `str` = 'hello'; - 註解: 請記得,字串都需加上 '' ``` let str = 'hello'; ``` 2. 輸入 `typeof str` ``` typeof str // 顯示答案: 'string' ``` - 其餘種類變數,後續將持續更新。 ###### tags: `Re:0 前端工程師之路 - JavaScript 初級 篇章`