O'Reilly logo

Node.js Web Development - Third Edition by David Herron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

ES-2015 multiline and template strings

The previous example showed two of the new features introduced with ES-2015, multiline and template strings. The feature is meant to simplify our life while creating text strings.

The existing string representations use single quotes and double quotes. Template strings are delimited with the backtick character that's also known as the grave accent (or, in French, accent grave):

`template string text`

Before ES-2015, one way to implement a multiline string was this construct:

["<html><head><title>Hello, world!</title></head>",
 "<body><h1>Hello, world!</h1>",
 "<p><a href='/osinfo'>OS Info</a></p>",
 "</body></html>"]
.join('\n')

Yes, this is the code used in the same example in previous versions of this book. This ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required