It just binds a string to the label attribute. In es6 instead of k + ". " + v
you can do ${k}. ${v}
to concatenate a string. In order to use the "feature", called template literals, the string must be in backticks instead of single or double quotes.
Some of the advantages of using template literals:
- Makes it easier to use multiline strings
- Makes it possible to use "nested templates" eg.
const classes = `header ${
isLargeScreen() ? "" : `icon-${item.isCollapsed ? "expander" : "collapser"}`
}`;
intead of doing something like:
let classes = "header";
classes += isLargeScreen()
? ""
: item.isCollapsed
? " icon-expander"
: " icon-collapser";
example from Mozilla. There are also more advantages listed there