From the course: Learning App Building with Vanilla JavaScript
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Template literals to build DOM content - JavaScript Tutorial
From the course: Learning App Building with Vanilla JavaScript
Template literals to build DOM content
- [Instructor] One of the really useful features of React is the ability to write JSX code. JSX let's you write a single string that include both literal content and variable values with the common curly bracket delimiters used in templating libraries like Mustache and Handlebars. Now, JSX also let's you pass literal HTML elements. And although React contains code to parse those safely, that's not a safe thing to do in Vanilla JavaScript without writing some extra code to secure it. But JavaScript does allow us to incorporate variable values with literal content in a single string known as a template literal. Template literals are a relatively new feature of JavaScript, but they're supported by all modern browsers. And you can easily transpile code that uses them into code that can be parsed by older browsers as well. Our app has one statement that combines property values from the state variable with literal content. And that's when we set the text content of the conditionsPara…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.