Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
prevent binding to all duplicated items of the object?

Please look at this svelte REPLE. when you duplicate an item then if you change the input of each duplicated item all other are changing. why is it? how to avoid this behavior?


https://svelte.dev/repl/991786b9def049249e185e5168afff5a?version=3.46.4


<script>
    const foodList = [
        { icon: '๐Ÿฒ', elem: "111" },
        { icon: '๐Ÿฅซ', elem: "222"},
        { icon: '๐Ÿ”', elem: "333" },
    ]; 
    const duplicate = (index) => { 
        foodList.splice(index +1, 0, foodList[index]);
        foodList = foodList;
    };
</script>

{#each foodList as {icon, elem}, index}
    <div>
        {icon} {elem}
        <input bind:value={elem} />
        <button  on:click={() => duplicate(index)} >duplicate</button>
    </div>
{/each}
about 4 years ago ยท Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!