Template substitutions offer a nice syntactic sugar in order to avoid concating strings. Example:
function authorize(user, action) {
if (!user.hasPrivilege(action)) {
throw new Error(
`User ${user.name} is not authorized to do ${action}.`);
}
}
They also add support for multiline strings that will look the way they are formated (eliminating the need to use special characters like \n, \t etc), making the code more readable.
Template substitutions offer a nice syntactic sugar in order to avoid concating strings. Example:
They also add support for multiline strings that will look the way they are formated (eliminating the need to use special characters like
\n
,\t
etc), making the code more readable.See this for more information.