svelte-flatpickr icon indicating copy to clipboard operation
svelte-flatpickr copied to clipboard

Why is this object re-assigned?

Open frederikhors opened this issue 2 years ago • 4 comments

REPL: https://svelte.dev/repl/953050f84c9d4f528ecfaaaf50defbbf?version=3.55.1

Using the below code I found that the first team is re-assigned, the second nope (see the console).

Why?

I expect to not get re-assigned when the date is already present.

This may seem negligible, but when there are 30+ components on a page it is not at all (performances).

<script>
  import Flatpickr from './flatpickr.svelte';

  // this assigns team 2 times
  let team = {id: "1", start_date: new Date()};

  // this not
  // let team = {id: "1"};

  $: console.log("team assigned:", team);
</script>

frederikhors avatar Jan 24 '23 20:01 frederikhors