Svelte · Junior · Question 6 of 76

How do you output a JavaScript value in Svelte markup?

<script>
  let name = "world";
</script>

<h1>Hello {name}!</h1>

Explanation

Any JavaScript expression can go inside the braces. Text is escaped automatically, so it's safe from HTML injection.

Further reading

Problem with a question

Svelte · Junior · question 6

Test yourself

Take the Svelte · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz