Svelte · Middle · Question 64 of 75

Can <select bind:value> hold objects, not just strings?

<select bind:value={selected}>
  {#each users as user}
    <option value={user}>{user.name}</option>
  {/each}
</select>

Explanation

With <select multiple> the bound value is an array.

Further reading

Problem with a question

Svelte · Middle · question 64

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