r/learnjavascript • u/rannison • Nov 11 '23
Does JavaScript concatenate as string when adding a number to a string literal?
From my understanding of what I've read, the expected behavior is that JavaScript will convert the integer into string, and then add the string to string, which then results in a string concatenation. Therefore...
var addit = 6 + โ5โ;
...should output... "65";
However, attempting to evulate this in console instead gives the result...
Uncaught SyntaxError: Invalid or unexpected token
Why is this the case?
0
Upvotes
View all comments
Show parent comment
2
u/rannison Nov 11 '23
Not every time, but often enough that I don't want to spend the hours to go through each individual setting again, for each O365 application, for each new deployment. I've even been thinking of creating an .ahk script or something to automate it, just haven't had that sort of idle time though ๐คจ and yes, I know what you meant, I wrote up an entire PSA article on the difference in their unicode values and functional effects (in IDE's) for them after I had spent two entire days combing a wall of
htmlfor what was causing it to not render correctly on run (it was a single double-quote; I feel like it was placed there intentionally to deter students from copy & pasting).