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

156
Views
Copy Date object without old data

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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>

about 4 years ago · Juan Pablo Isaza Report
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!