Javascript notes - Part 6 - Template literals

Javascript notes - Part 6 - Template literals

String interpolation and multiline strings in Javascript

Table of contents

No heading

No headings in the article.

Template literal is one of the best features in modern Javascript if not the best. Once You start using them, you will forget the old way of concatenating strings together just for including values from variables, etc.

Before

var welcome_message = "Hello <b>" + name + "</b>, Welcome to our website.<br/>" + 
"Use this email - <b>" + email + "</b> and password - <b>" + password + "</b> to login."

After

var welcome_message = `
    Hello <b>${name}</b>, Welcome to our website.<br/> 
    Use this email - <b>${email}</b> and password - <b>${password}</b> to login.
`