[JavaScript] 字串轉數字小技巧 - Lauct's BLOG
使用Number()指令轉換: a) var numOfShoes = '2'; var numOfSocks = 4; var totalItems = Number (numOfShoes) + numOfSocks; console. log (totalItems); result: 6 b)若字串裡只有英文沒有數字 var numOfShoes = 'a'; var numOfSocks = 4; var totalItems = Number ......