I'm trying to write custom deep clone functionality and I have some problems with the Date object. for examplelet now = {time: new Date()} or let now = {data: new Date().getDay()}, and I want to copy it, I don't need to copy current time, I only need to copy new Date() constructor, or new Date().getDay() functionality, for example, if I will run the original object now, and after a few days I will run the copy object, I don't need the same result, I need the recently get new Date() function result.
You can only get at the object as it were if you scan the source
Here using DOM as an example
const script = [...document.querySelectorAll("script")]
.filter(scr => scr.innerText.match(/let\s+now/))
if (script.length) console.log(script[0].textContent.trim())
<script>
let time = {data: new Date().getHours()}
console.log(JSON.parse(JSON.stringify(time)))
</script>
<script>
let now = {data: new Date().getDay()}
</script>