JavaScript · Senior · Question 19 of 75

What does a tagged template do?

const q = sql`SELECT * FROM users WHERE id = ${id}`;

Explanation

The tag function receives strings and the values separately, so it can safely escape substitutions or pass them as query parameters - protection against injections. That's how styled-components, graphql tags and String.raw work.

Further reading

Problem with a question

JavaScript · Senior · question 19

Test yourself

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

Take this quiz