{"id":39288,"date":"2025-11-16T02:17:13","date_gmt":"2025-11-16T10:17:13","guid":{"rendered":"https:\/\/cloudinary.com\/blog\/?p=39288"},"modified":"2025-11-16T02:17:14","modified_gmt":"2025-11-16T10:17:14","slug":"what-is-string-interpolation-in-javascript","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/","title":{"rendered":"What is string interpolation in JavaScript?"},"content":{"rendered":"\n<p>You might have seen threads where developers debate whether to use string concatenation or template literals for building UI strings, URLs, and logs. If you are juggling variables, function outputs, and formatting in the same string, understanding interpolation can boost readability and reduce bugs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Question:<\/h2>\n\n\n\n<p><em>Hi all,<\/em><br><em>I keep seeing template literals in code reviews and want to make sure I am using them correctly. What is string interpolation in JavaScript? How do I use it with template literals for variables, expressions, multiline strings, and conditional output? Are there pitfalls I should avoid, especially around security when inserting user input into the DOM?<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Answer:<\/h2>\n\n\n\n<p>String interpolation is the process of inserting the result of expressions directly into a string. In JavaScript, the modern way to do this is with template literals, which use backticks and the <code>${...}<\/code> placeholder. Let\u2019s dive a little deeper:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Template literal basics<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> name = <span class=\"hljs-string\">'Ari'<\/span>;\n<span class=\"hljs-keyword\">const<\/span> total = <span class=\"hljs-number\">19.99<\/span>;\n<span class=\"hljs-keyword\">const<\/span> message = <span class=\"hljs-string\">`Hi <span class=\"hljs-subst\">${name}<\/span>, your total is $<span class=\"hljs-subst\">${total.toFixed(<span class=\"hljs-number\">2<\/span>)}<\/span>.`<\/span>;\n<span class=\"hljs-built_in\">console<\/span>.log(message); <span class=\"hljs-comment\">\/\/ \"Hi Ari, your total is $19.99.\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li>Use backticks: <code>`...`<\/code><\/li>\n\n\n\n<li>Embed any JS expression in <code>${...}<\/code><\/li>\n\n\n\n<li>Supports multiline strings without <code>\\n<\/code><\/li>\n<\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> list = &#91;<span class=\"hljs-string\">'apples'<\/span>, <span class=\"hljs-string\">'oranges'<\/span>, <span class=\"hljs-string\">'pears'<\/span>];\n<span class=\"hljs-keyword\">const<\/span> summary = <span class=\"hljs-string\">`You bought:\n- <span class=\"hljs-subst\">${list.join(<span class=\"hljs-string\">'\\n- '<\/span>)}<\/span>\n\nThanks!`<\/span>;\n<span class=\"hljs-built_in\">console<\/span>.log(summary);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Expressions, conditionals, and functions<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> qty = <span class=\"hljs-number\">3<\/span>;\n<span class=\"hljs-keyword\">const<\/span> unit = <span class=\"hljs-number\">4.5<\/span>;\n<span class=\"hljs-keyword\">const<\/span> isMember = <span class=\"hljs-literal\">true<\/span>;\n\n<span class=\"hljs-keyword\">const<\/span> line = <span class=\"hljs-string\">`Subtotal: $<span class=\"hljs-subst\">${qty * unit}<\/span> <span class=\"hljs-subst\">${isMember ? <span class=\"hljs-string\">'(member discount applies)'<\/span> : <span class=\"hljs-string\">''<\/span>}<\/span>`<\/span>;\n<span class=\"hljs-built_in\">console<\/span>.log(line);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Common pitfalls<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Forgetting backticks.<\/strong> Single or double quotes do not interpolate.<\/li>\n\n\n\n<li><strong>Inserting unsanitized user input into HTML.<\/strong> String interpolation in JavaScript does not auto-escape, so always keep safety in mind.<\/li>\n\n\n\n<li><strong>Getting <\/strong><code>undefined<\/code><strong> or <\/strong><code>null<\/code><strong> in output.<\/strong> Use default values, such as <code>${val ?? 'N\/A'}<\/code>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Escaping backticks and placeholders<\/h3>\n\n\n\n<p><code>const literal = `Use backticks \\` and placeholders like \\${value}.`;<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Tagged templates for formatting and safety<\/h3>\n\n\n\n<p>Tagged templates let you post-process interpolated values, useful for formatting or escaping HTML.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php shcb-wrap-lines\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">escapeHTML<\/span><span class=\"hljs-params\">(strings, ...values)<\/span> <\/span>{\n\u00a0 <span class=\"hljs-keyword\">const<\/span> esc = v =&gt; String(v)\n\u00a0 \u00a0 .replace(\/&amp;\/g, <span class=\"hljs-string\">'&amp;amp;'<\/span>)\n\u00a0 \u00a0 .replace(\/&lt;\/g, <span class=\"hljs-string\">'&amp;lt;'<\/span>)\n\u00a0 \u00a0 .replace(\/&gt;\/g, <span class=\"hljs-string\">'&amp;gt;'<\/span>)\n\u00a0 \u00a0 .replace(\/<span class=\"hljs-string\">\"\/g, '&amp;quot;')\n\u00a0 \u00a0 .replace(\/'\/g, ''');\n\u00a0 return strings.reduce((out, str, i) =&gt; out + str + (i &lt; values.length ? esc(values&#91;i]) : ''), '');\n}\n\nconst userInput = '&lt;script&gt;alert(1)&lt;\/script&gt;';\nconst html = escapeHTML`&lt;div class=\"<\/span>note<span class=\"hljs-string\">\"&gt;${userInput}&lt;\/div&gt;`;\nconsole.log(html);<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Everyday patterns<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Building query strings:<\/li>\n<\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> params = <span class=\"hljs-keyword\">new<\/span> URLSearchParams({ <span class=\"hljs-attr\">q<\/span>: <span class=\"hljs-string\">'cats'<\/span>, <span class=\"hljs-attr\">page<\/span>: <span class=\"hljs-number\">2<\/span> });\n<span class=\"hljs-keyword\">const<\/span> url = <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>\/search?${params}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li>Formatting numbers and dates:<\/li>\n<\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> price = <span class=\"hljs-number\">39.5<\/span>;\n<span class=\"hljs-keyword\">const<\/span> formatted = <span class=\"hljs-string\">`Total: <span class=\"hljs-subst\">${<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">Intl<\/span>.NumberFormat(<span class=\"hljs-string\">'en-US'<\/span>, { style: <span class=\"hljs-string\">'currency'<\/span>, currency: <span class=\"hljs-string\">'USD'<\/span> }<\/span>).format(price)}`<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Using interpolation with media URLs and HTML<\/h3>\n\n\n\n<p>Interpolation is great for composing delivery URLs and markup. If your app constructs image links, it helps to know how an <a href=\"https:\/\/cloudinary.com\/glossary\/image-url\">image URL<\/a> is structured and how HTML images are embedded. See this guide to the <a href=\"https:\/\/cloudinary.com\/guides\/image-effects\/html-image-tag\">HTML image tag<\/a> for attributes and best practices.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-comment\">\/\/ Example: Building a responsive &lt;img&gt; with a dynamic srcset<\/span>\n<span class=\"hljs-keyword\">const<\/span> publicId = <span class=\"hljs-string\">'samples\/landscapes\/beach'<\/span>;\n<span class=\"hljs-keyword\">const<\/span> widths = &#91;<span class=\"hljs-number\">480<\/span>, <span class=\"hljs-number\">768<\/span>, <span class=\"hljs-number\">1080<\/span>];\n<span class=\"hljs-keyword\">const<\/span> srcset = widths.map(<span class=\"hljs-function\"><span class=\"hljs-params\">w<\/span> =&gt;<\/span>\n\u00a0 <span class=\"hljs-string\">`https:\/\/res.cloudinary.com\/demo\/image\/upload\/w_<span class=\"hljs-subst\">${w}<\/span>,c_fill\/<span class=\"hljs-subst\">${publicId}<\/span>.jpg <span class=\"hljs-subst\">${w}<\/span>w`<\/span>\n).join(<span class=\"hljs-string\">', '<\/span>);\n\n<span class=\"hljs-keyword\">const<\/span> imgHTML = <span class=\"hljs-string\">`\n\u00a0 &lt;img\n\u00a0 \u00a0 src=\"https:\/\/res.cloudinary.com\/demo\/image\/upload\/w_768,c_fill\/<span class=\"hljs-subst\">${publicId}<\/span>.jpg\"\n\u00a0 \u00a0 srcset=\"<span class=\"hljs-subst\">${srcset}<\/span>\"\n\u00a0 \u00a0 sizes=\"(max-width: 768px) 90vw, 768px\"\n\u00a0 \u00a0 alt=\"Beach\"\n\/&gt;`<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Enhancing the workflow with Cloudinary<\/h3>\n\n\n\n<p>After you grasp interpolation, you can pair it with Cloudinary to generate dynamic, performant media URLs on the fly.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Simple template literal URL:<\/li>\n<\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">const<\/span> w = <span class=\"hljs-number\">600<\/span>, h = <span class=\"hljs-number\">400<\/span>;\n<span class=\"hljs-keyword\">const<\/span> publicId = <span class=\"hljs-string\">'samples\/animals\/kitten'<\/span>;\n<span class=\"hljs-keyword\">const<\/span> cldUrl = <span class=\"xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>https:\/\/res.cloudinary.com\/demo\/image\/upload\/w_${w},h_${h},c_fill,q_auto,f_auto\/${publicId}.jpg<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><\/span>;\n<span class=\"hljs-comment\">\/\/ Use cldUrl in  or CSS<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<ul class=\"wp-block-list\">\n<li>Using the JavaScript SDK:<\/li>\n<\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\"><span class=\"hljs-keyword\">import<\/span> { Cloudinary } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'@cloudinary\/url-gen'<\/span>;\n<span class=\"hljs-keyword\">import<\/span> { fill } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'@cloudinary\/url-gen\/actions\/resize'<\/span>;\n\n<span class=\"hljs-keyword\">const<\/span> cld = <span class=\"hljs-keyword\">new<\/span> Cloudinary({ <span class=\"hljs-attr\">cloud<\/span>: { <span class=\"hljs-attr\">cloudName<\/span>: <span class=\"hljs-string\">'demo'<\/span> } });\n<span class=\"hljs-keyword\">const<\/span> w = <span class=\"hljs-number\">800<\/span>, h = <span class=\"hljs-number\">450<\/span>, publicId = <span class=\"hljs-string\">'samples\/poi\/bridge'<\/span>;\n<span class=\"hljs-keyword\">const<\/span> img = cld.image(publicId)\n\u00a0 .format(<span class=\"hljs-string\">'auto'<\/span>)\n\u00a0 .quality(<span class=\"hljs-string\">'auto'<\/span>)\n\u00a0 .resize(fill().width(w).height(h));\n<span class=\"hljs-keyword\">const<\/span> optimizedUrl = img.toURL();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>You can also explore helpful utilities in the <a href=\"https:\/\/cloudinary.com\/tools\">Cloudinary tools<\/a> collection.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Security tip<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Interpolation itself is safe, but inserting untrusted values into HTML is not. Escape or sanitize before injecting into the DOM.<\/li>\n\n\n\n<li>Prefer setting text content programmatically or using trusted template engines that auto-escape by default.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">TL;DR<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>String interpolation in JavaScript uses template literals with <code>${...}<\/code> to embed expressions in strings.<\/li>\n\n\n\n<li>It supports multiline strings, conditionals, and function calls, and it improves readability over concatenation.<\/li>\n\n\n\n<li>Escape or sanitize user input before injecting into HTML. Tagged templates can help.<\/li>\n\n\n\n<li>Combine interpolation with dynamic media URLs and delivery. See image URL structures and HTML image tag best practices for robust output.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Learn More<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/cloudinary.com\/tools\/image-to-webp\">Image to WebP<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/cloudinary.com\/tools\/png-to-webp\">PNG to WebP<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/cloudinary.com\/tools\/image-upscale\">Image Upscale<\/a><\/li>\n<\/ul>\n\n\n\n<p>Ready to build faster, more dynamic experiences with smart media delivery and transformation? <a href=\"https:\/\/cloudinary.com\/users\/register_free\">Sign up for a free Cloudinary account<\/a> and start optimizing your assets today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You might have seen threads where developers debate whether to use string concatenation or template literals for building UI strings, URLs, and logs. If you are juggling variables, function outputs, and formatting in the same string, understanding interpolation can boost readability and reduce bugs. Question: Hi all,I keep seeing template literals in code reviews and [&hellip;]<\/p>\n","protected":false},"author":88,"featured_media":39267,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[423],"class_list":["post-39288","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-questions"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>What is string interpolation in JavaScript?<\/title>\n<meta name=\"description\" content=\"You might have seen threads where developers debate whether to use string concatenation or template literals for building UI strings, URLs, and logs. If\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is string interpolation in JavaScript?\" \/>\n<meta property=\"og:description\" content=\"You might have seen threads where developers debate whether to use string concatenation or template literals for building UI strings, URLs, and logs. If\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-11-16T10:17:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-16T10:17:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"1999\" \/>\n\t<meta property=\"og:image:height\" content=\"1100\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"damjanantevski\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/\"},\"author\":{\"name\":\"damjanantevski\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/43592e43c12520a1e867d456b1e8cf7e\"},\"headline\":\"What is string interpolation in JavaScript?\",\"datePublished\":\"2025-11-16T10:17:13+00:00\",\"dateModified\":\"2025-11-16T10:17:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/\"},\"wordCount\":467,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA\",\"keywords\":[\"Questions\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/\",\"url\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/\",\"name\":\"What is string interpolation in JavaScript?\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA\",\"datePublished\":\"2025-11-16T10:17:13+00:00\",\"dateModified\":\"2025-11-16T10:17:14+00:00\",\"description\":\"You might have seen threads where developers debate whether to use string concatenation or template literals for building UI strings, URLs, and logs. If\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA\",\"width\":1999,\"height\":1100},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is string interpolation in JavaScript?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/43592e43c12520a1e867d456b1e8cf7e\",\"name\":\"damjanantevski\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3b40c995531fe4d510212a06c9d4fc666d2cb8efbfebc98a94191701accf4817?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3b40c995531fe4d510212a06c9d4fc666d2cb8efbfebc98a94191701accf4817?s=96&d=mm&r=g\",\"caption\":\"damjanantevski\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"What is string interpolation in JavaScript?","description":"You might have seen threads where developers debate whether to use string concatenation or template literals for building UI strings, URLs, and logs. If","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"What is string interpolation in JavaScript?","og_description":"You might have seen threads where developers debate whether to use string concatenation or template literals for building UI strings, URLs, and logs. If","og_url":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/","og_site_name":"Cloudinary Blog","article_published_time":"2025-11-16T10:17:13+00:00","article_modified_time":"2025-11-16T10:17:14+00:00","og_image":[{"width":1999,"height":1100,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA","type":"image\/jpeg"}],"author":"damjanantevski","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/"},"author":{"name":"damjanantevski","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/43592e43c12520a1e867d456b1e8cf7e"},"headline":"What is string interpolation in JavaScript?","datePublished":"2025-11-16T10:17:13+00:00","dateModified":"2025-11-16T10:17:14+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/"},"wordCount":467,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA","keywords":["Questions"],"inLanguage":"en-US","copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/","url":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/","name":"What is string interpolation in JavaScript?","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA","datePublished":"2025-11-16T10:17:13+00:00","dateModified":"2025-11-16T10:17:14+00:00","description":"You might have seen threads where developers debate whether to use string concatenation or template literals for building UI strings, URLs, and logs. If","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA","width":1999,"height":1100},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/questions\/what-is-string-interpolation-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"What is string interpolation in JavaScript?"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/43592e43c12520a1e867d456b1e8cf7e","name":"damjanantevski","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3b40c995531fe4d510212a06c9d4fc666d2cb8efbfebc98a94191701accf4817?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3b40c995531fe4d510212a06c9d4fc666d2cb8efbfebc98a94191701accf4817?s=96&d=mm&r=g","caption":"damjanantevski"}}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1763149247\/QA_javascript_featured_image\/QA_javascript_featured_image.jpg?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/39288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/88"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=39288"}],"version-history":[{"count":1,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/39288\/revisions"}],"predecessor-version":[{"id":39289,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/39288\/revisions\/39289"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/39267"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=39288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=39288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=39288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}