Combining strings in JavaScript has always been a bit messy. It involves a lot of quotation marks and plus signs, and it was almost always an exercise in trial and error:
When you ran the code, the spacing may be off. You forgot to close a quotation mark, so the entire output would look funky. If there is a line break, wellβ¦you had to Google to see what to do. If you havenβt lived through some of the chaos, you get the idea.
To help us solve this, we now have string literals:
String literals bring a lot of clarity by giving us a simple syntax optimized for generating our final string and marking the content we want to substitute by using the weirdly friendly $ and { } bracket syntax.
To learn more, check out my latest article on the site, appropriately (and very boringly) called Combining Strings and Variables. I walk through the traditional approach and the string literal approach along with some additional tidbits of information along the way.
Video Version
I have been creating videos of some of my more popular articles, such as this one. Check out the video version of our combining strings problem below:
There are a bunch of other videos on web development topics that you can find on this siteβs Youtube channel, so head on over and subscribe if you havenβt.
Arrays: The Book
If you are looking for a fun and easy-to-follow guide to learn about Arrays in JavaScript, look no further!
Till Next Time
All right! This marks another installment of our pithy newsletter on web development topics. If you ever have ideas for topics youβd like me to consider writing about or just want to chat about anything web development related, drop by the forumsβ¦just like it is 1999!
Oh, and follow me on Twitter as well. Youβll thank me one day.
View this email in your browser
Copyright (C) *|CURRENT_YEAR|* *|LIST:COMPANY|*. All rights reserved.
*|IFNOT:ARCHIVE_PAGE|**|LIST:DESCRIPTION|**|END:IF|*
*|IFNOT:ARCHIVE_PAGE|**|HTML:LIST_ADDRESS_HTML|**|END:IF|*
Update Preferences | Unsubscribe
*|IF:REWARDS|* *|HTML:REWARDS|* *|END:IF|*