<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rachel Lawson</title>
    <description>The latest articles on DEV Community by Rachel Lawson (@rachelmlawson).</description>
    <link>https://dev.to/rachelmlawson</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F456505%2Ff8d0662b-d45c-4c54-92a0-d9c83b446cdf.jpeg</url>
      <title>DEV Community: Rachel Lawson</title>
      <link>https://dev.to/rachelmlawson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rachelmlawson"/>
    <language>en</language>
    <item>
      <title>I Literally Can't With Template Literals: 3 Ways to Use Them</title>
      <dc:creator>Rachel Lawson</dc:creator>
      <pubDate>Fri, 13 Oct 2023 21:50:21 +0000</pubDate>
      <link>https://dev.to/rachelmlawson/i-literally-cant-with-template-literals-431l</link>
      <guid>https://dev.to/rachelmlawson/i-literally-cant-with-template-literals-431l</guid>
      <description>&lt;p&gt;As someone who is still working on my coding-fu, certain fancy-schmancy syntaxes can make me panic a little bit when I see them. One Javascript technique that has given me this kind of trouble in the past is the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals"&gt;template literal&lt;/a&gt; with its sophisticated backticks and dollar signs. &lt;/p&gt;

&lt;p&gt;In this article, my goal is to boil the concept down into the simplest explanation that makes sense to me. And if you, internet stranger, also struggle to remember how and when to use template literals, I hope it makes sense to you, too.&lt;/p&gt;

&lt;p&gt;The first thing you need to know is that template literals are surrounded with backticks (`), instead of the usual double or single quotes that you would use for strings.&lt;/p&gt;

&lt;p&gt;Let's focus on three uses of the template literal: &lt;strong&gt;multi-string lines&lt;/strong&gt;, &lt;strong&gt;string interpolation&lt;/strong&gt;, and &lt;strong&gt;tagged templates&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multi-string Lines
&lt;/h2&gt;

&lt;p&gt;With a template literal, you can easily make a string that includes multiple lines.&lt;/p&gt;

&lt;p&gt;If you're using a normal string and you want multiple lines, you have to do something like this:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9bse3t4ib77dcpytb6oz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9bse3t4ib77dcpytb6oz.png" alt="Multi-line string using normal string" width="800" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But with the magic of template literals, you can achieve this in a much more elegant way:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycdntvvpm99y8vq5kihs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fycdntvvpm99y8vq5kihs.png" alt="Multi-line string using template literal" width="696" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pretty simple, right?&lt;/p&gt;

&lt;h2&gt;
  
  
  String Interpolation
&lt;/h2&gt;

&lt;p&gt;This one is so useful. Before learning about template literals, if I wanted to include a variable value or an expression in a string, I would have to concatenate the variable or expression with the string(s) using the addition operator (&lt;code&gt;+&lt;/code&gt;). This can be time consuming and it looks messy. &lt;/p&gt;

&lt;p&gt;Enter string interpolation! This means that you can embed expressions directly into strings. By wrapping an expression with &lt;code&gt;${}&lt;/code&gt;, you can insert the result of the expression directly into the string. Doing it this way is &lt;em&gt;so&lt;/em&gt; much easier on the hands and the eyes.&lt;/p&gt;

&lt;p&gt;Here's an example.&lt;/p&gt;

&lt;p&gt;This:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4672hukyifgga7rzl3s2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4672hukyifgga7rzl3s2.png" alt="Inserting the result of an expression into a string using concatenation" width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Becomes this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnqp59ohap4hkwyyt2r3v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnqp59ohap4hkwyyt2r3v.png" alt="Inserting the result of an expression using string interpolation" width="800" height="179"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;String interpolation is way quicker than concatenating, especially when you're dealing with multiple variables/expressions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tagged Templates
&lt;/h2&gt;

&lt;p&gt;This one is more complex and trickier to understand initially, but still very useful. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates"&gt;Tagged template literals&lt;/a&gt; (aka tagged templates) allow you to parse a template literal with a function called a tag function.&lt;/p&gt;

&lt;p&gt;For example, you can pass the template literal to the tag function and have it return just the interpolated values (the results of the expressions surrounded by &lt;code&gt;${}&lt;/code&gt;) from the template literal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5bp4ao5n3swscaehcrpn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5bp4ao5n3swscaehcrpn.png" alt="Return interpolated values from template literal" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also return an array of strings, split up by the interpolated values. In other words, everything BUT the interpolated values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frh6y9fwsh51p1de0rng6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frh6y9fwsh51p1de0rng6.png" alt="Return strings from template literal" width="800" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: The rest parameter (&lt;code&gt;...&lt;/code&gt;) was used in this example. If this is unfamiliar to you, you can read more about it &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are more applications of template literals in JavaScript, but I think this is a good starting point. It's worth taking the time to get a basic grasp on this stuff, considering the time you will save yourself in the long run. And who doesn't want to be able to write fancy-schmancy code?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Belated Introduction</title>
      <dc:creator>Rachel Lawson</dc:creator>
      <pubDate>Thu, 21 Sep 2023 20:35:17 +0000</pubDate>
      <link>https://dev.to/rachelmlawson/a-belated-introduction-45jm</link>
      <guid>https://dev.to/rachelmlawson/a-belated-introduction-45jm</guid>
      <description>&lt;p&gt;Hi, I'm Rachel. I joined this community a few years ago, but I quickly got distracted with school and life and never did anything with it. Since then, I had a baby and graduated with my bachelor in IT.  &lt;/p&gt;

&lt;p&gt;Now that I'm done with my courses, I have some time to explore my interests and possibly choose a specialization. I've known for a long time that I wanted to work in tech, but I can see myself doing so many different things that it's hard to narrow it down! I started in the computer science program, picturing myself working as a software developer, but I felt bogged down and bored with all the theory of it. I'm a hands-on learner and it was hard to stay motivated and confident in my career direction without learning the tools or ever applying my knowledge. I also had the desire to explore things like hardware and networking, and ultimately decided to switch my major to information technology. I was happy with that direction and learned a ton, but now that I've graduated, I still feel that itch to code. &lt;/p&gt;

&lt;p&gt;At the moment, I am a full-time parent, but I plan to rejoin the work force soon. I'm using this time to explore some possible career paths - namely, web development and/or cloud computing. &lt;/p&gt;

&lt;p&gt;I love to write, so I'm hoping I can use this platform to chronicle my journey, solidify things I've learned, and keep up my momentum. &lt;/p&gt;

&lt;p&gt;I so appreciate your time if you’ve read this far! Whether you’re a fellow learner hoping to break into the industry, or a seasoned professional willing to share their experience, please feel free to say hey!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>introduction</category>
    </item>
  </channel>
</rss>
