[問題] js的字串和數字要分開嗎?

看板Web_Design作者 (不如憐取眼前人)時間11年前 (2013/10/08 01:55), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
如題,想請教如果我要寫 My birthday is March 1 2012. 那是不是要把 2012和字串分開呢? 例如寫成 "My birthday is March" + 1 2012? 會產生這樣的疑問是在於看到下面這個: Variables and Expressions Variables are used to hold values or expressions. An expression is any valid unit of code that resolves to a value. For example, "JavaScript is #" + 1 is an expression that resolves to "JavaScript is #1". An expression can also be a value, function, or object, which we will cover later in the course. When dealing with simple value expressions like 42, we usually just call them "value". 來源:http://www.learnstreet.com/ 這裡的resolve代表什麼意思呢?解答 or 分辨 or 使變成..? 它的文字為什麼和字串要分開呢 請多指教...謝謝大家~~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 36.224.196.145

10/08 01:59, , 1F
... 如果是fixed的string請寫死就好... 別徒增轉換
10/08 01:59, 1F

10/08 02:00, , 2F
這裡是說JS對這種非string的concat會自動去stringify
10/08 02:00, 2F

10/08 14:31, , 3F
你應該寫成 "My birthday is"+ date object吧 ....
10/08 14:31, 3F
文章代碼(AID): #1IKlMBJN (Web_Design)