About “5”-1 & “5”+1 in Javascript (plus and minus signs) [duplicate]
问题 This question already has answers here : Why does JavaScript handle the plus and minus operators between strings and numbers differently? (7 answers) Closed 4 years ago . I read a book about operators in Javascript, and this confused me. console.log("5"+1); This would make "5" as a string. So the result would be 51 . console.log("5"-1); This result would be 4 . I know it converts "5" to 5 , but why it isn't shown undefined as "a string minus a number"? Update: So how about other languages?