Search⌘ K

More JavaScript elements

Explore core JavaScript features including template literals for combining text and variables, the spread operator to expand iterables and objects, and destructuring assignments to simplify variable extraction. Understand how these elements improve code readability and efficiency when building front-end applications.

Template literals

Template literals are enclosed by backtick characters (") instead of double or single quotes. They allow a concise syntax for string values that result from a combination of fixed text parts and variables, including some multi-line string values.

Javascript (babel-node)
const classValues = "card important";
const name = "Joker";
const htmlTemplate = `<div class="${classValues}">
<p>Hello ${name}!</p>
</div>`
console.log(htmlTemplate)

The spread operator

The spread operator (...) can be used to ...