ES6 Template Strings

es6

Template Strings were introduced in ES 6 and allows us to:

  1. Perform strings concatenation without the + operators.
  2. Insert variables into a string.

Before we were used to concatenating strings using the + or , operators:

console.log(lastName + ", " + firstName + " " + middleName)

However with template strings we can insert variable values into our srings using the ${}:

console.log(`${lastName}, ${firstName} ${middleName}`)

Between the ${} you can add any Javascript expression that returns a value.

Template Strings preserve the whitespaces making it convenient for displaying things like code samples.

With template strings, our statement can span multiple lines of code.

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section. This feedback helps us gauge our progress.

Help me Grow.

I set myself some growth ambitions I desire to achieve by this year's end regarding this website and my youtube channel. Am halfway. Help me reach them by:




Recommendations


What do You Think


Previous Post