Quick JS: Template Literals

Oct 10, 2018 · 137 words · 1 minute read es6 js

My daily JavaScript journey has brought me to some es6 fundamentals. I wanted to start to build things that were more complicated than some DOM manipulation. I have been going through some courses, and naturally, the instructor has been showing us some of the differences between es5 and es6.

As I go back and learn some of the fundamentals of the language it is also nice to see where things are going next and new ways to do some things.

Lets take a look at a new way you can make multi line string templates.

const button = `<button class=“big” id=“button”>I Am A Button</button>`
;
const cssJS = `
  body {
		background: red;
	}
`;

The biggest things to note are the backticks. The example below shows that while small, it makes things simpler and more readable.