© 2024 fjorge. All rights reserved.
String Interpolation in Vanilla JavaScript
Working in Front-End (FE) frameworks really makes you appreciate string interpolation. If you are not working in a FE framework and still want this functionality, Template Literals formerly known as template strings in ES2015 are a great replacement. This handy tool lets you use string interpolation in vanilla javascript.
In ES6 this functionality is already built in so you can use something like the following:
let name = 'Fname Lname';
console.log(`Hello ${name}!`);
//returns Hello Fname Lname!