{"id":1639,"date":"2023-10-17T05:00:00","date_gmt":"2023-10-17T12:00:00","guid":{"rendered":"https:\/\/www.angulartraining.com\/daily-newsletter\/?p=1639"},"modified":"2023-10-04T14:28:06","modified_gmt":"2023-10-04T21:28:06","slug":"backticks-double-quotes-and-single-quotes","status":"publish","type":"post","link":"https:\/\/www.angulartraining.com\/daily-newsletter\/backticks-double-quotes-and-single-quotes\/","title":{"rendered":"Backticks, double quotes, and single quotes"},"content":{"rendered":"\n<p>When working with strings in Javascript, we have three options: Backticks, double quotes, and single quotes. Today, let&#8217;s look at when to use each of these and the pros and cons of each approach.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Single-quotes<\/h3>\n\n\n\n<p>Single quotes are the least exciting option because they have primarily cons:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"262\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-11-1024x262.png\" alt=\"\" class=\"wp-image-1640\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-11-1024x262.png 1024w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-11-300x77.png 300w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-11-768x196.png 768w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-11-1536x393.png 1536w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-11.png 1714w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Double-quotes<\/h3>\n\n\n\n<p>Double quotes get the job done most of the time but don&#8217;t shine when building template strings with multiple lines:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"262\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-12-1024x262.png\" alt=\"\" class=\"wp-image-1641\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-12-1024x262.png 1024w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-12-300x77.png 300w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-12-768x196.png 768w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-12-1536x393.png 1536w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-12.png 1714w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Backticks<\/h3>\n\n\n\n<p>Backticks are superior most of the time because they were designed to make template strings easy:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"358\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-13-1024x358.png\" alt=\"\" class=\"wp-image-1642\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-13-1024x358.png 1024w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-13-300x105.png 300w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-13-768x269.png 768w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-13-1536x538.png 1536w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/10\/image-13.png 1714w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>It&#8217;s been proven that there are no differences in performance when using backticks in modern Javascript. It&#8217;s also important to remember that with Angular, our TypeScript compiler will compile those backticks into double quotes if our compiler is set to any version of Javascript before ES6, so you don&#8217;t have to worry about browser compatibility either. All <a href=\"https:\/\/caniuse.com\/template-literals\" target=\"_blank\" rel=\"noopener\" title=\"\">modern browsers support template literals with backticks<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When working with strings in Javascript, we have three options: Backticks, double quotes, and single quotes. Today, let&#8217;s look at when to use each of these and the pros and cons of each approach. Single-quotes Single quotes are the least exciting option because they have primarily cons: Double-quotes Double quotes get the job done most [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-1639","post","type-post","status-publish","format-standard","hentry","category-javascript"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/comments?post=1639"}],"version-history":[{"count":2,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1639\/revisions"}],"predecessor-version":[{"id":1644,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1639\/revisions\/1644"}],"wp:attachment":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/media?parent=1639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/categories?post=1639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/tags?post=1639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}