Template literals, where were you?

Ever since I started work at a new company 4 weeks ago, I’ve been challenged to learn the new paradigms of the Javascript programming language.

Think of me as an OG Javascript programmer who’s still stuck in pre-ES2015 era. I’ve been stuck with jQuery and vanilla JS pre ES6 as my front-end tools for the last 8 years and I’m learning of the awesome tricks that comes with ES6 and any versions beyond it. Part of the reasons I’ve not advanceD is my focus on developing backend solutions using Python and PHP.

One thing that has struck me today is template literals which can achieve the following:

  • Using variables as text placeholders e.g. `Hello ${name}. Are you ok?`
  • No need to concatenate using the plus operator (+)
  • No need to use the plus operator for multi-lined strings. You can write HTML code as is within the back ticks (` `)
  • Add Javascript expressions such as addition calculations etc
  • CLEANER CODE

I’m definitely enjoying ES6/ ES2015 and looking forward to tackle ReactJS and VueJS soon.