Since ES6, you can use template literals:
const age = 3 console.log(`I'm ${age} years old!`)
P.S. Note the use of backticks: ``
.
Related Posts:
- How to interpolate variables in strings in JavaScript, without concatenation?
- How to check whether a string contains a substring in JavaScript?
- Check if a string has a certain piece of text [duplicate]
- How to convert a string to an integer in JavaScript?
- How do I make the first letter of a string uppercase in JavaScript?
- How do I make the first letter of a string uppercase in JavaScript?
- Creating multiline strings in JavaScript
- Creating multiline strings in JavaScript
- Split string into array
- How do you reverse a string in-place in JavaScript?
- What is the correct way to check for string equality in JavaScript?
- Check if a variable is a string in JavaScript
- What’s the best way to convert a number to a string in JavaScript?
- How to perform string interpolation in TypeScript?
- Check if a variable is a string in JavaScript
- How can I remove a character from a string using JavaScript?
- How to print elements from array with javascript
- How to remove text from a string?
- What does ${} (dollar sign and curly braces) mean in a string in Javascript?
- Delete first character of a string in Javascript
- ES6: Create Strings using Template Literals – Freecodecamp
- How do I check if string contains substring? [duplicate]
- How do I check if string contains substring?
- How can I get the last character in a string?
- How can I get the last character in a string?
- Count the number of occurrences of a character in a string in Javascript
- Converting an object to a string
- Anagrams finder in javascript
- How can I extract a number from a string in JavaScript?
- String.Format not work in TypeScript
- How to do case insensitive string comparison?
- How to remove part of a string?
- Escaping HTML strings with jQuery
- Replace all spaces in a string with ‘+’
- How to count string occurrence in string?
- Insert a string at a specific index
- Strip HTML from Text JavaScript
- Strip all non-numeric characters from string in JavaScript
- Wildcard string comparison in Javascript
- Replace spaces with dashes and make all letters lower-case
- Check if a JavaScript string is a URL
- How to make a word underline in Markdown
- JQuery – $ is not defined
- Is it possible to sandbox JavaScript running in the browser?
- RegEx Ignore Case
- What is the convention in JSON for empty vs. null?
- Generating random whole numbers in JavaScript in a specific range?
- How to extract extension from filename string in Javascript?
- keep getting “? Something is already running on port 3000” when I do npm start on react app
- React Context vs React Redux, when should I use each one?
- Regular expression : match either of two conditions?
- What is causing the error `string.split is not a function`?
- Difference between innerText, innerHTML and value?
- Uncaught TypeError: data.push is not a function
- Length of a JavaScript object
- TypeError: $(…).modal is not a function with bootstrap Modal
- How to do fade-in and fade-out with JavaScript and CSS
- I want to remove double quotes from a String
- Calculating median – javascript
- Vue is not defined
- How to remove all listeners in an element?
- How do I check if an object has a key in JavaScript?
- How to make your Discord Bot always active
- How to write inside a DIV box with javascript
- use Lodash to sort array of object by value
- Chrome/jQuery Uncaught RangeError: Maximum call stack size exceeded
- How to get unique values in an array
- How to fix Error: listen EADDRINUSE while using NodeJS?
- Set scroll position
- .filter is not a function
- Function overloading in Javascript – Best practices
- Wait until flag=true
- momentJS date string add 5 days
- When is a CDATA section necessary within a script tag?
- How to get scrollbar position with Javascript?
- where is create-react-app webpack config and files?
- How to wrap the content of the main tinyMCE editor with extra tags
- Rest API authentication issue when called from fetch request in bundle.js
- Javascript not working?
- Add Item to Custom TinyMCE Menu
- Listbox return wrong value in WordPress 3.9
- Logout user and delete cookies from the client side?
- How do developers add “Smooth Transitions” to their sites?
- How can I get my Calculate Contact Form 7 field to update with jQuery? [closed]
- Calling a WordPress Custom JavaScript file
- How do I know if I should enqueue JS code or just include it in ONE PHP function?
- How do I use this javascript correct with wordpress?
- How can I integrate yepnope.js with WordPress (and plugins)?
- How to set javascript options for select2 in PHP array of plugin
- Multiple jQuery inputs or binds in Customizer Control Javascripts
- How to display different content on the same page using different URLS
- Immediate (e.g. without DOMContentLoaded) JS not working
- Client side pre-save Javascript hook on all admin pages
- Script not working in post content
- How to identify which javascript is being executed
- How to keep close a sub-menu under homepage? [closed]
- How to implement custom URL handler to access JS modal content? [closed]
- Javascript 2 elements dependent onclick .toggle [closed]
- How to load JavaScript modules with script_loader_tag hook?
- How to securely set dynamic HTML content with JavaScript?