Svelte · Middle · Question 67 of 75

How do you check whether a context exists before reading it?

Explanation

getContext returns undefined for a missing key; getAllContexts returns the whole map, e.g. to pass it to mount.

Further reading

Problem with a question

Svelte · Middle · question 67

Test yourself

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

Take this quiz