JavaScript Numbers & String 互動小技巧
小知識教學類型: 網頁設計、網站製作
Wiki topics:
🌐 · Web Development
JavaScript Numbers & String 互動小技巧

JavaScript Numbers & String 互動小技巧
小知識教學類型: 網頁設計、網站製作
數字(Numbers)和字串 (String)之間,會因應一些條件的不同而processing 的處理效果亦會不同。
首先,最簡單的兩個數字相加: let a = 5; let b = 8; let c = a + b; (c的數值會是 13)
但當兩個字串相加時: let a = “5”; let b = “8”; let c = a + b; (c的值會是 “58”)
若果一個數字加上字串呢? let a = 5; let b = “8”; let c = a + b; (c的值會是 “58”,兩組都會轉變成字串看待)
若果一個字串加上數字呢? let a = “5”; let b = 8; let c = a + b; (c的值會是 “58”,兩組都會轉變成字串看待)
메타데이터
- post_id
- c7e50d4342d6
- slug
- javascript-numbers-string-互動小技巧-c7e50d4342d6
- url
- https://medium.com/@compbrother/javascript-numbers-string-%E4%BA%92%E5%8B%95%E5%B0%8F%E6%8A%80%E5%B7%A7-c7e50d4342d6
- canonical_url
- https://medium.com/@compbrother/javascript-numbers-string-%E4%BA%92%E5%8B%95%E5%B0%8F%E6%8A%80%E5%B7%A7-c7e50d4342d6
- author_url
- https://medium.com/@compbrother
- status
- ok
- fetched_at
- 2026-08-02 11:52:24